iOS 错误锦集

绝地灬酷狼 2022-06-03 06:45 717阅读 0赞

从今天开始,我打算把自己所有遇到的错误,无论大大小小,都保存下来,以供自己反思,少点粗心才能提高效率

1、This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

  1. 2017-12-20 21:29:03.954058+0800 SwiftLive[3749:2123191] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
  2. Stack:(
  3. 0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
  5. 2 CoreFoundation 0x000000018cbbaf28 <redacted> + 0
  6. 3 Foundation 0x000000018d7ad378 <redacted> + 128
  7. 4 Foundation 0x000000018d7ad0f8 <redacted> + 76
  8. 5 Foundation 0x000000018d5f9b48 <redacted> + 132
  9. 6 Foundation 0x000000018d7abd80 <redacted> + 112
  10. 7 UIKit 0x0000000192ce9eac <redacted> + 1692
  11. 8 QuartzCore 0x000000018feda274 <redacted> + 148
  12. 9 UIKit 0x000000019333a234 <redacted> + 64
  13. 10 QuartzCore 0x000000018fecede8 <redacted> + 292
  14. 11 QuartzCore 0x000000018fececa8 <redacted> + 32
  15. 12 QuartzCore 0x000000018fe4a34c <redacted> + 252
  16. 13 QuartzCore 0x000000018fe713ac <redacted> + 504
  17. 14 QuartzCore 0x000000018fe716d8 <redacted> + 244
  18. 15 libsystem_pthread.dylib 0x000000018bc7be20 <redacted> + 572
  19. 16 libsystem_pthread.dylib 0x000000018bc7bb48 <redacted> + 200
  20. 17 libsystem_pthread.dylib 0x000000018bc7b1d8 _pthread_wqthread + 1312
  21. 18 libsystem_pthread.dylib 0x000000018bc7acac start_wqthread + 4
  22. )

从上面的报错信息可以看出,线程在运行的时候子线程修改了主线程UI的布局约束,在iOS开发中,所有的有关界面UI的更新操作必须要在主线程中完成。

在需要的时候,加上下面这句吧:

dispatch_async(dispatch_get_main_queue(), ^{ //inset code….

});

2、attempting to add unsupported attribute: (null)

  1. 2017-12-22 16:31:25.357 SwiftLive[3878:2402908] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInternalInconsistencyException', reason: 'attempting to add unsupported attribute: (null)'
  2. (
  3. 0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
  5. 2 CoreFoundation 0x000000018cbbaeb4 <redacted> + 0
  6. 3 Foundation 0x000000018d653760 <redacted> + 112
  7. 4 SwiftLive 0x00000001007c47d0 -[MASViewConstraint setSecondViewAttribute:] + 772
  8. 5 SwiftLive 0x00000001007c5730 __40-[MASViewConstraint equalToWithRelation]_block_invoke + 1756
  9. 6 SwiftLive 0x00000001007be424 __24-[MASConstraint equalTo]_block_invoke + 100
  10. 7 SwiftLive 0x000000010017741c __29-[FLGiftSendView configureUI]_block_invoke.66 + 516
  11. 8 SwiftLive 0x00000001007cbfd8 -[UIView(MASAdditions) mas_makeConstraints:] + 132
  12. 9 SwiftLive 0x0000000100175b7c -[FLGiftSendView configureUI] + 752
  13. 10 SwiftLive 0x00000001001757c4 -[FLGiftSendView initWithFrame:] + 332
  14. 11 SwiftLive 0x000000010045eb2c -[FLChooseGiftsView setupUI] + 3680
  15. 12 SwiftLive 0x000000010045dbb4 -[FLChooseGiftsView init] + 136
  16. 13 SwiftLive 0x0000000100291570 -[FLLiveMainInterfaceViewController setupContentView] + 4680
  17. 14 SwiftLive 0x000000010028f3bc -[FLLiveMainInterfaceViewController setupUI] + 2708
  18. 15 SwiftLive 0x00000001002881e0 -[FLLiveMainInterfaceViewController viewDidLoad] + 344
  19. 16 UIKit 0x0000000192cecb04 <redacted> + 1036
  20. 17 UIKit 0x0000000192d04590 <redacted> + 132
  21. 18 UIKit 0x0000000192e88e18 <redacted> + 1144
  22. 19 UIKit 0x0000000192da37bc <redacted> + 676
  23. 20 UIKit 0x0000000192da3424 <redacted> + 64
  24. 21 UIKit 0x0000000192da3388 <redacted> + 188
  25. 22 UIKit 0x0000000192ce9cc0 <redacted> + 1200
  26. 23 QuartzCore 0x000000018feda274 <redacted> + 148
  27. 24 QuartzCore 0x000000018fecede8 <redacted> + 292
  28. 25 QuartzCore 0x000000018fececa8 <redacted> + 32
  29. 26 QuartzCore 0x000000018fe4a34c <redacted> + 252
  30. 27 QuartzCore 0x000000018fe713ac <redacted> + 504
  31. 28 QuartzCore 0x000000018fe71e78 <redacted> + 120
  32. 29 CoreFoundation 0x000000018cb689a8 <redacted> + 32
  33. 30 CoreFoundation 0x000000018cb66630 <redacted> + 372
  34. 31 CoreFoundation 0x000000018cb66a7c <redacted> + 956
  35. 32 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 424
  36. 33 GraphicsServices 0x000000018e501074 GSEventRunModal + 100
  37. 34 UIKit 0x0000000192d51c9c UIApplicationMain + 208
  38. 35 SwiftLive 0x0000000100437dd8 main + 312
  39. 36 libdyld.dylib 0x000000018baa559c <redacted> + 4
  40. )

从上面的报错信息,没有什么意外,就是上一个控件布局有问题,或者是布局的顺序有问题,也有可能是约束冲突,或者约束不全。

使用Masonry要注意约束的完整性。否则就会出现上述报错。

3、今天很坑的一个事情,我想写一个不固定高度的View,View里面放一些控件,我还要给View描边,整个布局布局好以后,发现View里面的控件没有出来,然后我各种看小面包,左边显示控件是存在的,右边的界面却和真机一样没有出来,苦了我又是设置背景颜色调试,又是各种检查布局的,下面是我布局的代码:

SouthEast

约束检查了一遍又一遍,还是没有任何思路,这里要感谢师父一直给我提示,给我一些调试的方法,我就感觉,应该还是布局的问题,于是我改了如下代码:

  1. 我将
  2. make.height.mas_lessThanOrEqualTo(33 * ScreenHeightRatio);

这句代码改成了

  1. make.height.mas_equalTo(33 * ScreenHeightRatio);

结果就可以了,说明用masorny布局,不确定高度的View,是不可以描边等操作的,会出现一系列的问题,可怜我太菜,这个问题调试了很久

4、关于IOS开发之关于UIButton点击没有响应问题

在做UI界面的时候,确认butten 是最后添加的呀,但是,怎么就不响应点击方法呢?小面包查了一遍又一遍,真的是粗心误大事,哭

  1. 感谢在网上找到的资料,保存一下:

1、如果一个UIButton的frame超出父视图的frame,UIButton还是可以显现的,但响应不了点击事件了,当开发中,遇到UIButton点击没有响应问题时,我们需要输出btn及它父视图的frame,看看btn.frame是否超出view

2、还可以通过Debug—->View Debugging—->show ViewFrames查看按钮上层是否有透明视图。

我的是第一种:UIButten控件大小超出了父控件的大小,所以响应不了点击事件了。

5、-[__NSCFDictionary length]: unrecognized selector sent to instance 0x171c60980’

出错在类型上面,我定义的是nsnumber类型,而拿到的是后天返回的是nsstring类型,直接赋值了,小白果然效率低,哎。。。。。。。。。。


  1. 2017-12-23 19:29:41.451 SwiftLive[4057:2610494] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary length]: unrecognized selector sent to instance 0x171c60980'
  2. (
  3. 0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
  5. 2 CoreFoundation 0x000000018cbc1ef4 <redacted> + 0
  6. 3 CoreFoundation 0x000000018cbbef54 <redacted> + 916
  7. 4 CoreFoundation 0x000000018cabad4c _CF_forwarding_prep_0 + 92
  8. 5 UIKit 0x0000000192cf66c8 <redacted> + 312
  9. 6 SwiftLive 0x000000010014f574 -[FLGiftSendView tableView:didSelectRowAtIndexPath:] + 900
  10. 7 UIKit 0x0000000192e17a9c <redacted> + 1200
  11. 8 UIKit 0x0000000192ec7820 <redacted> + 268
  12. 9 UIKit 0x0000000192f79594 <redacted> + 292
  13. 10 UIKit 0x0000000192f6b630 <redacted> + 528
  14. 11 UIKit 0x0000000192cdf28c <redacted> + 132
  15. 12 CoreFoundation 0x000000018cb689a8 <redacted> + 32
  16. 13 CoreFoundation 0x000000018cb66630 <redacted> + 372
  17. 14 CoreFoundation 0x000000018cb66a7c <redacted> + 956
  18. 15 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 424
  19. 16 GraphicsServices 0x000000018e501074 GSEventRunModal + 100
  20. 17 UIKit 0x0000000192d51c9c UIApplicationMain + 208
  21. 18 SwiftLive 0x000000010040ba24 main + 312
  22. 19 libdyld.dylib 0x000000018baa559c <redacted> + 4
  23. )

解决:NSString 转 NSNumber :

  1. lastSeletNum = @([self.comeShowArray[indexPath.row][@"gift_num"] integerValue]);

6、不能同时比较:

  1. 我将一个string类型的字符串转换成int 类型,然后对齐比较大小,结果报了如下警告:

Comparison of constant 10 with boolean expression is always true

呼呼,不开森,iOS不能同时比较耶,要用&& 链接去比较

错误的代码如下:

  1. if (1 <= [listModle.liver_grade integerValue] <= 10) { self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel1_10"]; }else if (11 <= [listModle.liver_grade integerValue] <= 20){ self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel11_20"]; }else if (21 <= [listModle.liver_grade integerValue] <= 30){ self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel21_30"]; }else if (31 <= [listModle.liver_grade integerValue] <= 40){ self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel31_40"]; }else if (41 <= [listModle.liver_grade integerValue] <= 50){ self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel41_50"]; }

正确的代码如下:

  1. NSInteger grade = [listModle.liver_grade integerValue];
  2. if (1 <= grade && grade <= 10) {
  3. self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel1_10"];
  4. }else if (11 <= grade && grade <= 20){
  5. self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel11_20"];
  6. }else if (21 <= grade && grade <= 30){
  7. self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel21_30"];
  8. }else if (31 <= grade && grade <= 40){
  9. self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel31_40"];
  10. }else if (41 <= grade && grade <= 50){
  11. self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel41_50"];
  12. }

7、应用在iPhone5 iPhone5s 上不全屏,上下各有黑块

在网上找到如下原因:

a、 没有添加适配iPhone的 640 * 1136 分辨率的图片

b、 整个工程中,有没有一个地方在设置画面高度时候使用了固定值480或568等,一般都是直接获取屏幕大小,然后再设置画面大小的。

c、如果用的有xib,就在xib里面设置一下view的自动布局;如果用的是纯代码,就手动设置UIView的autoLayout

d、UI给的图片有问题,或者自己没有把图片的位置放好

我就是属于第四种,各种办法试了试,如下配置正确:

SouthEast 1

启动图也都有:

SouthEast 2

结果就是有如下问题:

SouthEast 3

我就把启动图都删了,换上上家公司的启动图片,结果没有问题,所有就是现在UI给的启动图有问题喽,让UI重新学习iOS启动图切图,放上,就木有问题啦!

8、CollectionView 上拉加载更多 刷新闪屏

在网上找了很多方法,不过好像并没有特别有用,最后采取的办法有如下几种,不过都感觉效果一般,先记下来,后面再试试:

  1. 方法一:
  2. [UIView setAnimationsEnabled:NO];
  3. [collectionView performBatchUpdates:^{
  4. [collectionView reloadData];
  5. } completion:^(BOOL finished) {
  6. [UIView setAnimationsEnabled:YES];
  7. }];

方法二:

  1. [UIView animateWithDuration:0 animations:^{
  2. [collectionView performBatchUpdates:^{
  3. [collectionView reloadData];
  4. } completion:nil];
  5. }];

注意:performBatchUpdates 这个方法是collectionView原来有数据的时候,上拉刷新才能用,第一次 reloaData 就调用这个方法,会崩溃的呦 QAQ

方法三:

  1. NSMutableArray*indexPaths = [[NSMutableArray alloc] init];
  2. for ( inti =0; i < model.mediumArr.count; i ++) {
  3. NSIndexPath *indexPath = [NSIndexPath indexPathForRow: self.dataSource.count+ i in Section: 0];
  4. [indexPaths addObject: indexPath];
  5. }
  6. [self.dataSource addObjectsFromArray: model.mediumArr];
  7. [self.collectionView insertItemsAtIndexPaths: indexPaths];
  8. [UIView performWithoutAnimation:^{
  9. [self.collectionView reloadItemsAtIndexPaths: indexPaths];
  10. }];

注:model.mediumArr为加载进来的新数据源,也就是上啦加载出来的数据(数组)

具体想用哪个方法,自己试试看看拿个更好一些,后面找到更好的方法,会持续更新

9、图片填充方式:

1、UIViewContentModeScaleAspectFit, //这个图片都会在view里面显示,并且比例不变 这就是说 如果图片和view的比例不一样 就会有留白

2、UIViewContentModeScaleAspectFill, // 这是整个view会被图片填满,图片比例不变 ,这样图片显示就会大于view

3、Scale to Fill: 缩放图片,使图片充满容器。没有aspect,图片未必保持长宽比例协调,有可能会拉伸至变形。

  1. 4 UIViewContentModeCenter 中间为中心

5、UIViewContentModeTop 以上面为主

6、UIViewContentModeBottom 以下面为主

7、UIViewContentModeLeft 以左边为主

8、UIViewContentModeRight

9、UIViewContentModeTopLeft

10、UIViewContentModeTopRight

11、UIViewContentModeBottomLeft

12、UIViewContentModeBottomRight

13、UIViewContentModeLeft

14、UIViewContentModeLeft

15、UIViewContentModeLeft

10、’-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x102288570’

报错信息如下:

  1. 2017-12-28 19:38:14.259 SwiftLive[1327:1606209] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x102288570'
  2. (
  3. 0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
  6. 3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
  7. 4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
  8. 5 SwiftLive 0x00000001001a1e3c -[FLAttentionViewController collectionView:didSelectItemAtIndexPath:] + 476
  9. 6 UIKit 0x000000018cdb9ad4 <redacted> + 596
  10. 7 UIKit 0x000000018cdb9468 <redacted> + 596
  11. 8 UIKit 0x000000018cd34e84 <redacted> + 336
  12. 9 UIKit 0x000000018cd7f500 <redacted> + 60
  13. 10 UIKit 0x000000018cd34e84 <redacted> + 336
  14. 11 UIKit 0x000000018cd7f500 <redacted> + 60
  15. 12 UIKit 0x000000018cd34e84 <redacted> + 336
  16. 13 UIKit 0x000000018cd7f500 <redacted> + 60
  17. 14 UIKit 0x000000018d166c90 <redacted> + 4484
  18. 15 UIKit 0x000000018d162d28 <redacted> + 1164
  19. 16 UIKit 0x000000018d162848 <redacted> + 408
  20. 17 UIKit 0x000000018d161b04 <redacted> + 268
  21. 18 UIKit 0x000000018cbd0a44 <redacted> + 2960
  22. 19 UIKit 0x000000018cba152c <redacted> + 340
  23. 20 UIKit 0x000000018d38ea54 <redacted> + 2736
  24. 21 UIKit 0x000000018d3884bc <redacted> + 784
  25. 22 CoreFoundation 0x0000000186cf4278 <redacted> + 24
  26. 23 CoreFoundation 0x0000000186cf3bc0 <redacted> + 524
  27. 24 CoreFoundation 0x0000000186cf17c0 <redacted> + 804
  28. 25 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
  29. 26 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
  30. 27 UIKit 0x000000018cc0c2fc <redacted> + 684
  31. 28 UIKit 0x000000018cc07034 UIApplicationMain + 208
  32. 29 SwiftLive 0x000000010037b6d0 main + 312
  33. 30 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
  34. )

刚一开始看,以为是数据解析错误,但是明明是看着打印出的数据解析的,没有问题啊,郁闷的宝宝又去找师傅,师父说,肯定是你没字典转模型啊

确实,后台返的数组里面嵌套有字典,然后忘了写:

  1. - (void)setValue:(id)value forKey:(NSString *)key
  2. {
  3. if ([key isEqualToString:@"live_info"])
  4. {
  5. [super setValue:value forKey:key];
  6. }else
  7. {
  8. NSString *string = [NSString stringWithFormat:@"%@", value];
  9. [super setValue:string forKey:key];
  10. }
  11. }

师父果然腻害,笨笨的我,总是丢三落四

11、大家新年快乐,今天继续上班,遇到了一个小小的问题:

*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil

  1. 2018-01-02 14:43:32.923 SwiftLive[1046:427525] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
  2. (
  3. 0 CoreFoundation 0x0000000181f2aff8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018098c538 objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000181e0c898 CFStringConvertNSStringEncodingToEncoding + 0
  6. 3 SwiftLive 0x000000010018e110 -[FLRefreshHeaderView imagesArr] + 336
  7. 4 SwiftLive 0x000000010018e684 -[FLRefreshHeaderView setRefreshState:] + 60
  8. 5 SwiftLive 0x000000010018da74 -[FLRefreshHeaderView refreshView] + 792
  9. 6 SwiftLive 0x000000010018f178 -[FLRefreshHeaderView setState:] + 1516
  10. 7 SwiftLive 0x00000001007c1aa0 -[MJRefreshComponent initWithFrame:] + 200
  11. 8 SwiftLive 0x000000010018d700 -[FLRefreshHeaderView init] + 76
  12. 9 SwiftLive 0x00000001007c524c +[MJRefreshHeader headerWithRefreshingTarget:refreshingAction:] + 92
  13. 10 SwiftLive 0x000000010021bd20 -[FLLiveListViewController setUpRefreshView] + 88
  14. 11 SwiftLive 0x000000010021bb40 -[FLLiveListViewController viewDidLoad] + 876
  15. 12 UIKit 0x000000018805cb04 <redacted> + 1036
  16. 13 UIKit 0x000000018805c6e0 <redacted> + 28
  17. 14 SwiftLive 0x000000010012b0ec -[FLHomeViewController collectionView:cellForItemAtIndexPath:] + 436
  18. 15 UIKit 0x00000001889564a0 <redacted> + 448
  19. 16 UIKit 0x00000001880bd3f0 <redacted> + 3820
  20. 17 UIKit 0x00000001880b8018 <redacted> + 300
  21. 18 UIKit 0x0000000188059cc0 <redacted> + 1200
  22. 19 QuartzCore 0x000000018524a274 <redacted> + 148
  23. 20 QuartzCore 0x000000018523ede8 <redacted> + 292
  24. 21 QuartzCore 0x000000018523eca8 <redacted> + 32
  25. 22 QuartzCore 0x00000001851ba34c <redacted> + 252
  26. 23 QuartzCore 0x00000001851e13ac <redacted> + 504
  27. 24 UIKit 0x00000001882f4840 <redacted> + 140
  28. 25 CoreFoundation 0x0000000181ed930c <redacted> + 20
  29. 26 CoreFoundation 0x0000000181ed8b28 <redacted> + 288
  30. 27 CoreFoundation 0x0000000181ed6998 <redacted> + 728
  31. 28 CoreFoundation 0x0000000181e06da4 CFRunLoopRunSpecific + 424
  32. 29 GraphicsServices 0x0000000183871074 GSEventRunModal + 100
  33. 30 UIKit 0x00000001880c1c9c UIApplicationMain + 208
  34. 31 SwiftLive 0x000000010044771c main + 312
  35. 32 libdyld.dylib 0x0000000180e1559c <redacted> + 4
  36. )

这个出错的原因主要是,我们的一个帧动画需要替换,UI直接用我原来的图的名称命名的,便于我替换,不过帧的多少是不一样的,我把图片直接拉进去,代码里面的帧数改了,多余的帧的图片却忘记拉进项目,找不到对应的图,自然崩溃

12、-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000643

  1. 2018-01-03 14:39:38.703 SwiftLive[1681:2148751] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000643'
  2. (
  3. 0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
  6. 3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
  7. 4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
  8. 5 UIKit 0x000000018cbab7bc <redacted> + 108
  9. 6 UIKit 0x000000018cbab6b4 <redacted> + 128
  10. 7 UIKit 0x000000018cca1afc <redacted> + 96
  11. 8 UIKit 0x000000018cca18f0 <redacted> + 52
  12. 9 UIKit 0x000000018cca1458 <redacted> + 488
  13. 10 UIKit 0x000000018d4f3b78 <redacted> + 76
  14. 11 UIKit 0x000000018d4f289c <redacted> + 192
  15. 12 UIKit 0x000000018d4f2be4 <redacted> + 632
  16. 13 UIKit 0x000000018d4f2b6c <redacted> + 512
  17. 14 UIKit 0x000000018d4f2b6c <redacted> + 512
  18. 15 UIKit 0x000000018d4f2b6c <redacted> + 512
  19. 16 UIKit 0x000000018d4f2b6c <redacted> + 512
  20. 17 UIKit 0x000000018d4f2b6c <redacted> + 512
  21. 18 UIKit 0x000000018d4f2b6c <redacted> + 512
  22. 19 Foundation 0x0000000187775480 <redacted> + 168
  23. 20 UIKit 0x000000018d4f338c <redacted> + 84
  24. 21 UIKit 0x000000018d4f254c <redacted> + 136
  25. 22 UIKit 0x000000018d4f2f94 <redacted> + 164
  26. 23 UIKit 0x000000018d4f3f00 <redacted> + 364
  27. 24 UIKit 0x000000018ce9add4 <redacted> + 180
  28. 25 UIKit 0x000000018cb9e220 <redacted> + 1196
  29. 26 QuartzCore 0x000000018a05e188 <redacted> + 148
  30. 27 QuartzCore 0x000000018a052e64 <redacted> + 292
  31. 28 QuartzCore 0x000000018a052d24 <redacted> + 32
  32. 29 QuartzCore 0x0000000189fcf7ec <redacted> + 252
  33. 30 QuartzCore 0x0000000189ff6c58 <redacted> + 512
  34. 31 QuartzCore 0x0000000189ff7678 <redacted> + 120
  35. 32 CoreFoundation 0x0000000186cf37dc <redacted> + 32
  36. 33 CoreFoundation 0x0000000186cf140c <redacted> + 372
  37. 34 CoreFoundation 0x0000000186cf189c <redacted> + 1024
  38. 35 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
  39. 36 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
  40. 37 UIKit 0x000000018cc0c2fc <redacted> + 684
  41. 38 UIKit 0x000000018cc07034 UIApplicationMain + 208
  42. 39 SwiftLive 0x00000001003f7454 main + 312
  43. 40 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
  44. )

每次从后台拿到值的时候,总忘判断后天传过来的值的类型,呢,又出错了,后台的给我的是长整型的变量,我赋值给了string类型。

13、the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (UICollectionElementKindSectionHeader, {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null))

  1. 2018-01-03 16:00:21.895 SwiftLive[1712:2166430] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (UICollectionElementKindSectionHeader,<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null))'
  2. (
  3. 0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000186d46094 <redacted> + 0
  6. 3 Foundation 0x00000001877d379c <redacted> + 112
  7. 4 UIKit 0x000000018cd24044 <redacted> + 932
  8. 5 UIKit 0x000000018cc02678 <redacted> + 3868
  9. 6 UIKit 0x000000018cbfd0a4 <redacted> + 288
  10. 7 UIKit 0x000000018cb9e220 <redacted> + 1196
  11. 8 QuartzCore 0x000000018a05e188 <redacted> + 148
  12. 9 QuartzCore 0x000000018a052e64 <redacted> + 292
  13. 10 QuartzCore 0x000000018a052d24 <redacted> + 32
  14. 11 QuartzCore 0x0000000189fcf7ec <redacted> + 252
  15. 12 QuartzCore 0x0000000189ff6c58 <redacted> + 512
  16. 13 QuartzCore 0x0000000189ff7678 <redacted> + 120
  17. 14 CoreFoundation 0x0000000186cf37dc <redacted> + 32
  18. 15 CoreFoundation 0x0000000186cf140c <redacted> + 372
  19. 16 CoreFoundation 0x0000000186cf189c <redacted> + 1024
  20. 17 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
  21. 18 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
  22. 19 UIKit 0x000000018cc0c2fc <redacted> + 684
  23. 20 UIKit 0x000000018cc07034 UIApplicationMain + 208
  24. 21 SwiftLive 0x0000000100397478 main + 312
  25. 22 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
  26. )

这个不是太确定,应该是要判断collectionView的header的section要确定下来,不能直接返回nil?有大神看到了帮忙解答下,蟹蟹。

14、**-[__NSSingleObjectArrayI objectForKey:]: unrecognized selector sent to instance 0x174011cd0**

  1. 2018-01-03 16:12:37.485 SwiftLive[1725:2170098] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleObjectArrayI objectForKey:]: unrecognized selector sent to instance 0x174011cd0'
  2. (
  3. 0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
  6. 3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
  7. 4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
  8. 5 Foundation 0x00000001877ea800 <redacted> + 212
  9. 6 SwiftLive 0x000000010036ac88 -[FLDiscoveryViewController dealRequestDataErrorWithOffset:] + 1092
  10. 7 SwiftLive 0x000000010036a5c4 -[FLDiscoveryViewController refreshData] + 404
  11. 8 SwiftLive 0x00000001006eac0c __47-[MJRefreshComponent executeRefreshingCallback]_block_invoke + 372
  12. 9 libdispatch.dylib 0x0000000101f1925c _dispatch_call_block_and_release + 24
  13. 10 libdispatch.dylib 0x0000000101f1921c _dispatch_client_callout + 16
  14. 11 libdispatch.dylib 0x0000000101f1e284 _dispatch_main_queue_callback_4CF + 1200
  15. 12 CoreFoundation 0x0000000186cf3f2c <redacted> + 12
  16. 13 CoreFoundation 0x0000000186cf1b18 <redacted> + 1660
  17. 14 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
  18. 15 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
  19. 16 UIKit 0x000000018cc0c2fc <redacted> + 684
  20. 17 UIKit 0x000000018cc07034 UIApplicationMain + 208
  21. 18 SwiftLive 0x000000010036f4a0 main + 312
  22. 19 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
  23. )

这里就狠坑啦,主要还是窝是个小白,应该是字典转模型的,但是我取出来的是数组,而不是字段,根据打印,一看就是数组,怎么会不蹦捏!

字典:

  1. {
  2. avatar = "http://tx-upload.hk.ufileos.com/c229b79525a8a1e276d8e7c6817aab26.jpg";
  3. "avatar_small" = "http://tx-upload.hk.ufileos.com/cca6661843afcd4953539a0dc220da50.jpg";
  4. country = "";
  5. "create_time" = 1514957449;
  6. "current_count" = 0;
  7. "end_time" = 0;
  8. gender = 0;
  9. "great_sort" = 0;
  10. "hls_endpoint" = "http://hls.ylive.avazuinc.com:9090/hls/av3598/index.m3u8";
  11. "hot_sort" = 0;
  12. "like_sort" = 0;
  13. "live_id" = 3598;
  14. "live_pic" = "";
  15. "liver_exp" = 208080;
  16. "liver_grade" = 4;
  17. "liver_next_exp" = 319300;
  18. "new_sort" = 0;
  19. nick = test123;
  20. "people_count" = 300;
  21. signature = "";
  22. status = 2;
  23. "streaming_endpoint" = "rtmp://source.publish.olivestream.tv/live/av3598";
  24. title = "test123 on live";
  25. uid = 828;
  26. "update_time" = 1514957449;
  27. "viewing_endpoint" = "http://rtmp.pull.olivestream.tv/live/av3598.flv";
  28. }

数组:

  1. (
  2. {
  3. avatar = "http://tx-upload.hk.ufileos.com/c229b79525a8a1e276d8e7c6817aab26.jpg";
  4. "avatar_small" = "http://tx-upload.hk.ufileos.com/cca6661843afcd4953539a0dc220da50.jpg";
  5. country = "";
  6. "create_time" = 1514957449;
  7. "current_count" = 0;
  8. "end_time" = 0;
  9. gender = 0;
  10. "great_sort" = 0;
  11. "hls_endpoint" = "http://hls.ylive.avazuinc.com:9090/hls/av3598/index.m3u8";
  12. "hot_sort" = 0;
  13. "like_sort" = 0;
  14. "live_id" = 3598;
  15. "live_pic" = "";
  16. "liver_exp" = 208080;
  17. "liver_grade" = 4;
  18. "liver_next_exp" = 319300;
  19. "new_sort" = 0;
  20. nick = test123;
  21. "people_count" = 300;
  22. signature = "";
  23. status = 2;
  24. "streaming_endpoint" = "rtmp://source.publish.olivestream.tv/live/av3598";
  25. title = "test123 on live";
  26. uid = 828;
  27. "update_time" = 1514957449;
  28. "viewing_endpoint" = "http://rtmp.pull.olivestream.tv/live/av3598.flv";
  29. }
  30. )

15、网络状态不好的时候,明明设置了刷新超时,却明显超过了自己设置的超时时间,还在加载QAQ

原来代码如下:

SouthEast 4

感谢师父告诉我,这样是不对滴,

timeoutInterval 已经没有了作用。不管是同步还是异步。

这个问题只有在3.0以及之后的os中才有的,而且只有在当调用了setHTTPBody之后才会出现timeout失效。这个是苹果公司对URL Loading System的在iOS3.0中的一个改动,所有要改代码:

  1. [request setTimeoutInterval:10.0f];

改成

  1. [self.manager.requestSerializer setTimeoutInterval:10.0f];

感谢师父!

16、-[__NSCFNumber boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0xb000000000d33a13

  1. 2018-01-04 21:03:39.929 SwiftLive[1935:2427284] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber boundingRectWithSize:options:attributes:context:]: unrecognized selector sent to instance 0xb000000000d33a13'
  2. (
  3. 0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
  5. 2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
  6. 3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
  7. 4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
  8. 5 SwiftLive 0x000000010023cb50 -[FLChatRoomInfoView stringRect:fontSize:constraintWidth:constraintHeight:] + 288
  9. 6 SwiftLive 0x00000001002354b0 -[FLChatRoomInfoView updateUIWithAnchor:liveRoomInfo:isFollow:] + 2736
  10. 7 SwiftLive 0x00000001001e1cd0 -[FLLiveMainInterfaceViewController setupContentView] + 3844
  11. 8 SwiftLive 0x00000001001dfe60 -[FLLiveMainInterfaceViewController setupUI] + 2708
  12. 9 SwiftLive 0x00000001001d8be0 -[FLLiveMainInterfaceViewController viewDidLoad] + 372
  13. 10 UIKit 0x000000018cba10b0 <redacted> + 1056
  14. 11 UIKit 0x000000018cbb8c44 <redacted> + 132
  15. 12 UIKit 0x000000018cd41190 <redacted> + 1136
  16. 13 UIKit 0x000000018cc59858 <redacted> + 676
  17. 14 UIKit 0x000000018cc594c0 <redacted> + 64
  18. 15 UIKit 0x000000018cc59424 <redacted> + 188
  19. 16 UIKit 0x000000018cb9e220 <redacted> + 1196
  20. 17 QuartzCore 0x000000018a05e188 <redacted> + 148
  21. 18 QuartzCore 0x000000018a052e64 <redacted> + 292
  22. 19 QuartzCore 0x000000018a052d24 <redacted> + 32
  23. 20 QuartzCore 0x0000000189fcf7ec <redacted> + 252
  24. 21 QuartzCore 0x0000000189ff6c58 <redacted> + 512
  25. 22 QuartzCore 0x0000000189ff7678 <redacted> + 120
  26. 23 CoreFoundation 0x0000000186cf37dc <redacted> + 32
  27. 24 CoreFoundation 0x0000000186cf140c <redacted> + 372
  28. 25 CoreFoundation 0x0000000186cf189c <redacted> + 1024
  29. 26 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
  30. 27 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
  31. 28 UIKit 0x000000018cc0c2fc <redacted> + 684
  32. 29 UIKit 0x000000018cc07034 UIApplicationMain + 208
  33. 30 SwiftLive 0x000000010038e380 main + 312
  34. 31 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
  35. )

boundingRectWithSize:options:attributes:context:

是计算字符串宽度的方法,而后台传过来的是nsnumber类型的,所以出错了,你没看错,我每天都在出错中度过

17、在 UIScrollView上面添加了一个View,点击View的时候,页面上滑了一下,测试过来提bug,emmmm,可是宝宝看了层级关系,没有可点击的东西啊,QAQ

  1. 师父快来救我:

关于scrollView点击状态栏列表回到顶部的说明,想要禁用掉此功能将scrollsToTop属性设置为NO即可。

18、去除cell的点击后的选中背景:

方法一:自定义cell里面:

  1. - (void)awakeFromNib {
  2. [super awakeFromNib];
  3. self.selectionStyle = UITableViewCellSelectionStyleNone;
  4. }

方法二: 设置tableView的allowsSelection属性 注意:属性为NO的时候 tableView的代理方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 就不会执行 ,所以如果需要有cell点击事件的 不要用此方法

  1. tableView.allowsSelection = NO;

方法三:更改cell属性selectedBackgroundView 的背景色

我们选中cell时有灰色效果就是因为selectedBackgroundView这个家伙,所以,我们可以通过设置改View的背景色来改变选中颜色

  1. self.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
  2. self.selectedBackgroundView.backgroundColor = [UIColor redColor];

注意点:

1, 在storyboard设置tableView属性的时候 如果这样设置 selection: NoSelection

会导致点击cell的时候没反应 不会调用 didSelectRowAtIndexPath 方法

要想有点击方法应设置成 selection: SingleSelection

19、-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000033

  1. 2018-01-18 18:17:17.217 SwiftLive[1168:493865] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000033'
  2. (
  3. 0 CoreFoundation 0x00000001818a2ff8 <redacted> + 148
  4. 1 libobjc.A.dylib 0x0000000180304538 objc_exception_throw + 56
  5. 2 CoreFoundation 0x00000001818a9ef4 <redacted> + 0
  6. 3 CoreFoundation 0x00000001818a6f54 <redacted> + 916
  7. 4 CoreFoundation 0x00000001817a2d4c _CF_forwarding_prep_0 + 92
  8. 5 UIKit 0x00000001879de58c <redacted> + 108
  9. 6 UIKit 0x00000001879de484 <redacted> + 124
  10. 7 UIKit 0x0000000187ad29c0 <redacted> + 272
  11. 8 UIKit 0x0000000187ad2704 <redacted> + 52
  12. 9 UIKit 0x0000000187ad2230 <redacted> + 488
  13. 10 UIKit 0x0000000188335ca0 <redacted> + 112
  14. 11 UIKit 0x000000018833492c <redacted> + 192
  15. 12 UIKit 0x0000000188334c74 <redacted> + 624
  16. 13 UIKit 0x0000000188334bfc <redacted> + 504
  17. 14 UIKit 0x0000000188334bfc <redacted> + 504
  18. 15 UIKit 0x0000000188334bfc <redacted> + 504
  19. 16 UIKit 0x0000000188334bfc <redacted> + 504
  20. 17 UIKit 0x0000000188334bfc <redacted> + 504
  21. 18 UIKit 0x0000000188334bfc <redacted> + 504
  22. 19 UIKit 0x0000000188334bfc <redacted> + 504
  23. 20 Foundation 0x00000001822dca7c <redacted> + 168
  24. 21 UIKit 0x0000000188335410 <redacted> + 88
  25. 22 UIKit 0x0000000188334340 <redacted> + 116
  26. 23 UIKit 0x0000000188335024 <redacted> + 164
  27. 24 UIKit 0x0000000188336070 <redacted> + 432
  28. 25 UIKit 0x00000001879e596c <redacted> + 892
  29. 26 SwiftLive 0x000000010022f88c __69-[FLLiveMainInterfaceViewController showDialogWithUserInfo:withType:]_block_invoke.1225 + 84
  30. 27 UIKit 0x0000000187a093dc <redacted> + 644
  31. 28 UIKit 0x0000000187b4da24 <redacted> + 100
  32. 29 SwiftLive 0x000000010022f518 -[FLLiveMainInterfaceViewController showDialogWithUserInfo:withType:] + 620
  33. 30 SwiftLive 0x0000000100234a58 -[FLLiveMainInterfaceViewController chatMessageShowUserDetail:withType:] + 84
  34. 31 SwiftLive 0x00000001000f3cb4 -[FLChatMessageView getUserDetails:] + 1920
  35. 32 SwiftLive 0x00000001000f3ef0 -[FLChatMessageView showUserInfo:] + 444
  36. 33 UIKit 0x0000000187fa5d38 <redacted> + 64
  37. 34 UIKit 0x0000000187fa956c <redacted> + 124
  38. 35 UIKit 0x0000000187b63470 <redacted> + 252
  39. 36 UIKit 0x0000000187a05380 <redacted> + 720
  40. 37 UIKit 0x0000000187f99810 <redacted> + 988
  41. 38 UIKit 0x0000000187f993e0 <redacted> + 404
  42. 39 UIKit 0x0000000187f9868c <redacted> + 268
  43. 40 UIKit 0x0000000187a0370c <redacted> + 3164
  44. 41 UIKit 0x00000001879d433c <redacted> + 340
  45. 42 UIKit 0x00000001881ce014 <redacted> + 2400
  46. 43 UIKit 0x00000001881c8770 <redacted> + 4268
  47. 44 UIKit 0x00000001881c8b9c <redacted> + 148
  48. 45 CoreFoundation 0x000000018185142c <redacted> + 24
  49. 46 CoreFoundation 0x0000000181850d9c <redacted> + 540
  50. 47 CoreFoundation 0x000000018184e9a8 <redacted> + 744
  51. 48 CoreFoundation 0x000000018177eda4 CFRunLoopRunSpecific + 424
  52. 49 GraphicsServices 0x00000001831e8074 GSEventRunModal + 100
  53. 50 UIKit 0x0000000187a39058 UIApplicationMain + 208
  54. 51 SwiftLive 0x00000001003dc848 main + 312
  55. 52 libdyld.dylib 0x000000018078d59c <redacted> + 4
  56. )

这个错误可能是因为 把整形变量直接赋值给NSString类型变量,没有进行转化。

我错在了,拿到后台的数据是Int类型,赋值给了我自己定义的String类型QAQ

发表评论

表情:
评论列表 (有 0 条评论,717人围观)

还没有评论,来说两句吧...

相关阅读

    相关 前端面试

    > 基本面试: > 做过最满意的项目是什么?项目背景?为什么要做这件事情?最终达到什么效果?你处于什么样的角色,起到了什么方面的作用?在项目中遇到什么技术问题?具体是如何解

    相关 iOS 错误

       从今天开始,我打算把自己所有遇到的错误,无论大大小小,都保存下来,以供自己反思,少点粗心才能提高效率 1、This application i