- 崩溃错误:
-[NSConcreteTextStorage KeyBoardshow:]: unrecognized selector sent to instance 0x134537ab0
- 错误原因:通知用来监控键盘,二次调用的时候会导致崩溃。
- 解决方法:当前控制器用完监控,要移除掉观察者。否则再别的控制器,使用键盘观察会被触发,会在类中搜索,没有该方法,会抛出错误。
- 崩溃错误:
Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]
- 错误原因:AFNetworking请求中含有中文时程序崩溃.
- 解决方法:处理urlString的编码。
//方法一 str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //方法二 str = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; //方法三 str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- 崩溃错误:使用3D模式绘制地图的时候报错
-[BaseMapView initWithFrame:] exception:*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
- 错误原因:可能是你正在使用的AMap.bundle是for 2D。
- 解决方法:去官网的相关下载中下载3D地图的DEMO,把DEMO中的AMap.bundle拷贝引用到你的项目。
- 崩溃问题:
Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UITableView.m:7927
- 错误原因:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
这个方法返回的值为空 - 解决方法: if(cell) 改为 if(cell == nil)。ORN粗心大意。
- 崩溃问题:
*** Collection <__NSArrayM: 0xb550c30> was mutated while being enumerated.’
- 问题原因:你一边便利数组,同时又修改这个数组里面的内容,导致崩溃。
- 解决方法:
方法一:做一个完全一样的数组,数组A用来便利,数组B在便利里面修改。
方法二:数组的一个方法可以实现[tempArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (条件) { *stop = YES; if (*stop == YES) { [tempArray removeObject:obj]; }}}];
- 崩溃问题:
-[NSMutableIndexSet addIndexesInRange:]: Range {2147483647, 1} exceeds maximum index value of NSNotFound - 1’
- 错误原因:
[pickerV selectRow:[yeaArray indexOfObject:curYeaStr] inComponent:1 animated:YES];
selectRow
中的[yeaArray indexOfObject:curYeaStr]
在yeaArray
中没找到curYeaStr
。 - 解决方法:将
curYeaArray
的类型改成yeaArray
中object
的类型。
- 崩溃信息:
[__NSCFString containsString:]: unrecognized selector sent to instance
断点位置:if([str containsString:@"*"]) { // do something }
- 崩溃原因:出现在iOS7系统,iOS8以上没有这个错误。
- (BOOL)containsString:(NSString *)aString NS_AVAILABLE(10_10, 8_0);
这个方法在8.0后出现的。 - 解决方法:
判断“*”是否在字符串str中有位置NSRange range = [str rangeOfString:@“*"]; if(range.length > 0) {// do something } if(range.location != NSNotFound) {// do something }
- 崩溃信息:
-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[5]’
. - 错误原因:字典传空值
- 解决方法:字典传值前加判断
- 崩溃信息:
-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x177cc850
- 错误原因:用手写输入法打字的时候,出现闪退(只有手写输入法会这样),提示上述信息。是因为UIScrollView的category类重写了下述方法,来处理<在UIScrollview不触发UITouches的回收键盘的事件>,让UIScrollView的手势向下传递,这样对对系统的手写键盘造成了影响。
//这三个类,解决UIScrollView不能触发UITouch回收键盘事件 //用touch事件来达到轻拍视图回收键盘的效果 //touch scrollView的时候,让事件向下传递 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [[self nextResponder] touchesBegan:touches withEvent:event]; [super touchesBegan:touches withEvent:event]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [[self nextResponder] touchesMoved:touches withEvent:event]; [super touchesMoved:touches withEvent:event]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [[self nextResponder] touchesEnded:touches withEvent:event]; [super touchesEnded:touches withEvent:event]; }
- 解决方法
1.在UIScrollView上面加一个UIView,通过在view上面的手势来回收键盘
2.在UITableView上回收键盘UITapGestureRecognizer *tapSV = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard:)]; tapSV.cancelsTouchesInView = NO; [scrollV addGestureRecognizer: tapSV];
UITapGestureRecognizer *tapTV = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard:)]; //不加会屏蔽到TableView的点击事件等 tapTV.cancelsTouchesInView = NO; [tableView addGestureRecognizer:tapTV];