iOS问题-崩溃错误

  1. 崩溃错误-[NSConcreteTextStorage KeyBoardshow:]: unrecognized selector sent to instance 0x134537ab0
  2. 错误原因:通知用来监控键盘,二次调用的时候会导致崩溃。
  3. 解决方法:当前控制器用完监控,要移除掉观察者。否则再别的控制器,使用键盘观察会被触发,会在类中搜索,没有该方法,会抛出错误。


  1. 崩溃错误
    Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]
  2. 错误原因:AFNetworking请求中含有中文时程序崩溃.
  3. 解决方法:处理urlString的编码。
    //方法一
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //方法二
    str = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    //方法三
    str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];


  1. 崩溃错误:使用3D模式绘制地图的时候报错-[BaseMapView initWithFrame:] exception:*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
  2. 错误原因:可能是你正在使用的AMap.bundle是for 2D。
  3. 解决方法:去官网的相关下载中下载3D地图的DEMO,把DEMO中的AMap.bundle拷贝引用到你的项目。


  1. 崩溃问题
    Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UITableView.m:7927
  2. 错误原因:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 这个方法返回的值为空
  3. 解决方法: if(cell) 改为 if(cell == nil)。ORN粗心大意。


  1. 崩溃问题*** Collection <__NSArrayM: 0xb550c30> was mutated while being enumerated.’
  2. 问题原因:你一边便利数组,同时又修改这个数组里面的内容,导致崩溃。
  3. 解决方法:
    方法一:做一个完全一样的数组,数组A用来便利,数组B在便利里面修改。
    方法二:数组的一个方法可以实现
    [tempArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
      if (条件) {
             *stop = YES;
           if (*stop == YES) {
               [tempArray removeObject:obj];
          }}}];


  1. 崩溃问题-[NSMutableIndexSet addIndexesInRange:]: Range {2147483647, 1} exceeds maximum index value of NSNotFound - 1’
  2. 错误原因:[pickerV selectRow:[yeaArray indexOfObject:curYeaStr] inComponent:1 animated:YES];
    selectRow中的[yeaArray indexOfObject:curYeaStr]yeaArray中没找到curYeaStr
  3. 解决方法:将curYeaArray的类型改成yeaArrayobject的类型。


  1. 崩溃信息[__NSCFString containsString:]: unrecognized selector sent to instance
    断点位置:if([str containsString:@"*"]) { // do something }
  2. 崩溃原因:出现在iOS7系统,iOS8以上没有这个错误。
    - (BOOL)containsString:(NSString *)aString NS_AVAILABLE(10_10, 8_0);这个方法在8.0后出现的。
  3. 解决方法:
    判断“*”是否在字符串str中有位置
    NSRange range = [str rangeOfString:@“*"];
    if(range.length > 0)      {// do something  }  
    if(range.location != NSNotFound)  {// do something  }


  1. 崩溃信息-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[5]’.
  2. 错误原因:字典传空值
  3. 解决方法:字典传值前加判断


  1. 崩溃信息-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x177cc850
  2. 错误原因:用手写输入法打字的时候,出现闪退(只有手写输入法会这样),提示上述信息。是因为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];  
    }
  3. 解决方法
    1.在UIScrollView上面加一个UIView,通过在view上面的手势来回收键盘
    UITapGestureRecognizer *tapSV = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard:)];  
    tapSV.cancelsTouchesInView = NO;  
    [scrollV addGestureRecognizer: tapSV];
    2.在UITableView上回收键盘
    UITapGestureRecognizer *tapTV = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard:)];  
    //不加会屏蔽到TableView的点击事件等  
    tapTV.cancelsTouchesInView = NO;  
    [tableView addGestureRecognizer:tapTV];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值