iOS 错误锦集
从今天开始,我打算把自己所有遇到的错误,无论大大小小,都保存下来,以供自己反思,少点粗心才能提高效率
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.
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.
Stack:(
0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
2 CoreFoundation 0x000000018cbbaf28 <redacted> + 0
3 Foundation 0x000000018d7ad378 <redacted> + 128
4 Foundation 0x000000018d7ad0f8 <redacted> + 76
5 Foundation 0x000000018d5f9b48 <redacted> + 132
6 Foundation 0x000000018d7abd80 <redacted> + 112
7 UIKit 0x0000000192ce9eac <redacted> + 1692
8 QuartzCore 0x000000018feda274 <redacted> + 148
9 UIKit 0x000000019333a234 <redacted> + 64
10 QuartzCore 0x000000018fecede8 <redacted> + 292
11 QuartzCore 0x000000018fececa8 <redacted> + 32
12 QuartzCore 0x000000018fe4a34c <redacted> + 252
13 QuartzCore 0x000000018fe713ac <redacted> + 504
14 QuartzCore 0x000000018fe716d8 <redacted> + 244
15 libsystem_pthread.dylib 0x000000018bc7be20 <redacted> + 572
16 libsystem_pthread.dylib 0x000000018bc7bb48 <redacted> + 200
17 libsystem_pthread.dylib 0x000000018bc7b1d8 _pthread_wqthread + 1312
18 libsystem_pthread.dylib 0x000000018bc7acac start_wqthread + 4
)
从上面的报错信息可以看出,线程在运行的时候子线程修改了主线程UI的布局约束,在iOS开发中,所有的有关界面UI的更新操作必须要在主线程中完成。
在需要的时候,加上下面这句吧:
dispatch_async(dispatch_get_main_queue(), ^{ //inset code….
});
2、attempting to add unsupported attribute: (null)
2017-12-22 16:31:25.357 SwiftLive[3878:2402908] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInternalInconsistencyException', reason: 'attempting to add unsupported attribute: (null)'
(
0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
2 CoreFoundation 0x000000018cbbaeb4 <redacted> + 0
3 Foundation 0x000000018d653760 <redacted> + 112
4 SwiftLive 0x00000001007c47d0 -[MASViewConstraint setSecondViewAttribute:] + 772
5 SwiftLive 0x00000001007c5730 __40-[MASViewConstraint equalToWithRelation]_block_invoke + 1756
6 SwiftLive 0x00000001007be424 __24-[MASConstraint equalTo]_block_invoke + 100
7 SwiftLive 0x000000010017741c __29-[FLGiftSendView configureUI]_block_invoke.66 + 516
8 SwiftLive 0x00000001007cbfd8 -[UIView(MASAdditions) mas_makeConstraints:] + 132
9 SwiftLive 0x0000000100175b7c -[FLGiftSendView configureUI] + 752
10 SwiftLive 0x00000001001757c4 -[FLGiftSendView initWithFrame:] + 332
11 SwiftLive 0x000000010045eb2c -[FLChooseGiftsView setupUI] + 3680
12 SwiftLive 0x000000010045dbb4 -[FLChooseGiftsView init] + 136
13 SwiftLive 0x0000000100291570 -[FLLiveMainInterfaceViewController setupContentView] + 4680
14 SwiftLive 0x000000010028f3bc -[FLLiveMainInterfaceViewController setupUI] + 2708
15 SwiftLive 0x00000001002881e0 -[FLLiveMainInterfaceViewController viewDidLoad] + 344
16 UIKit 0x0000000192cecb04 <redacted> + 1036
17 UIKit 0x0000000192d04590 <redacted> + 132
18 UIKit 0x0000000192e88e18 <redacted> + 1144
19 UIKit 0x0000000192da37bc <redacted> + 676
20 UIKit 0x0000000192da3424 <redacted> + 64
21 UIKit 0x0000000192da3388 <redacted> + 188
22 UIKit 0x0000000192ce9cc0 <redacted> + 1200
23 QuartzCore 0x000000018feda274 <redacted> + 148
24 QuartzCore 0x000000018fecede8 <redacted> + 292
25 QuartzCore 0x000000018fececa8 <redacted> + 32
26 QuartzCore 0x000000018fe4a34c <redacted> + 252
27 QuartzCore 0x000000018fe713ac <redacted> + 504
28 QuartzCore 0x000000018fe71e78 <redacted> + 120
29 CoreFoundation 0x000000018cb689a8 <redacted> + 32
30 CoreFoundation 0x000000018cb66630 <redacted> + 372
31 CoreFoundation 0x000000018cb66a7c <redacted> + 956
32 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 424
33 GraphicsServices 0x000000018e501074 GSEventRunModal + 100
34 UIKit 0x0000000192d51c9c UIApplicationMain + 208
35 SwiftLive 0x0000000100437dd8 main + 312
36 libdyld.dylib 0x000000018baa559c <redacted> + 4
)
从上面的报错信息,没有什么意外,就是上一个控件布局有问题,或者是布局的顺序有问题,也有可能是约束冲突,或者约束不全。
使用Masonry要注意约束的完整性。否则就会出现上述报错。
3、今天很坑的一个事情,我想写一个不固定高度的View,View里面放一些控件,我还要给View描边,整个布局布局好以后,发现View里面的控件没有出来,然后我各种看小面包,左边显示控件是存在的,右边的界面却和真机一样没有出来,苦了我又是设置背景颜色调试,又是各种检查布局的,下面是我布局的代码:
约束检查了一遍又一遍,还是没有任何思路,这里要感谢师父一直给我提示,给我一些调试的方法,我就感觉,应该还是布局的问题,于是我改了如下代码:
我将
make.height.mas_lessThanOrEqualTo(33 * ScreenHeightRatio);
这句代码改成了
make.height.mas_equalTo(33 * ScreenHeightRatio);
结果就可以了,说明用masorny布局,不确定高度的View,是不可以描边等操作的,会出现一系列的问题,可怜我太菜,这个问题调试了很久
4、关于IOS开发之关于UIButton点击没有响应问题
在做UI界面的时候,确认butten 是最后添加的呀,但是,怎么就不响应点击方法呢?小面包查了一遍又一遍,真的是粗心误大事,
感谢在网上找到的资料,保存一下:
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类型,直接赋值了,小白果然效率低,哎。。。。。。。。。。
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'
(
0 CoreFoundation 0x000000018cbbaff8 <redacted> + 148
1 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 56
2 CoreFoundation 0x000000018cbc1ef4 <redacted> + 0
3 CoreFoundation 0x000000018cbbef54 <redacted> + 916
4 CoreFoundation 0x000000018cabad4c _CF_forwarding_prep_0 + 92
5 UIKit 0x0000000192cf66c8 <redacted> + 312
6 SwiftLive 0x000000010014f574 -[FLGiftSendView tableView:didSelectRowAtIndexPath:] + 900
7 UIKit 0x0000000192e17a9c <redacted> + 1200
8 UIKit 0x0000000192ec7820 <redacted> + 268
9 UIKit 0x0000000192f79594 <redacted> + 292
10 UIKit 0x0000000192f6b630 <redacted> + 528
11 UIKit 0x0000000192cdf28c <redacted> + 132
12 CoreFoundation 0x000000018cb689a8 <redacted> + 32
13 CoreFoundation 0x000000018cb66630 <redacted> + 372
14 CoreFoundation 0x000000018cb66a7c <redacted> + 956
15 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 424
16 GraphicsServices 0x000000018e501074 GSEventRunModal + 100
17 UIKit 0x0000000192d51c9c UIApplicationMain + 208
18 SwiftLive 0x000000010040ba24 main + 312
19 libdyld.dylib 0x000000018baa559c <redacted> + 4
)
解决:NSString 转 NSNumber :
lastSeletNum = @([self.comeShowArray[indexPath.row][@"gift_num"] integerValue]);
6、不能同时比较:
我将一个string类型的字符串转换成int 类型,然后对齐比较大小,结果报了如下警告:
Comparison of constant 10 with boolean expression is always true
呼呼,不开森,iOS不能同时比较耶,要用&& 链接去比较
错误的代码如下:
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"]; }
正确的代码如下:
NSInteger grade = [listModle.liver_grade integerValue];
if (1 <= grade && grade <= 10) {
self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel1_10"];
}else if (11 <= grade && grade <= 20){
self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel11_20"];
}else if (21 <= grade && grade <= 30){
self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel21_30"];
}else if (31 <= grade && grade <= 40){
self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel31_40"];
}else if (41 <= grade && grade <= 50){
self.popularityImg.image = [UIImage imageNamed:@"icon_little_anchorlevel41_50"];
}
7、应用在iPhone5 iPhone5s 上不全屏,上下各有黑块
在网上找到如下原因:
a、 没有添加适配iPhone的 640 * 1136 分辨率的图片
b、 整个工程中,有没有一个地方在设置画面高度时候使用了固定值480或568等,一般都是直接获取屏幕大小,然后再设置画面大小的。
c、如果用的有xib,就在xib里面设置一下view的自动布局;如果用的是纯代码,就手动设置UIView的autoLayout
d、UI给的图片有问题,或者自己没有把图片的位置放好
我就是属于第四种,各种办法试了试,如下配置正确:
启动图也都有:
结果就是有如下问题:
我就把启动图都删了,换上上家公司的启动图片,结果没有问题,所有就是现在UI给的启动图有问题喽,让UI重新学习iOS启动图切图,放上,就木有问题啦!
8、CollectionView 上拉加载更多 刷新闪屏
在网上找了很多方法,不过好像并没有特别有用,最后采取的办法有如下几种,不过都感觉效果一般,先记下来,后面再试试:
方法一:
[UIView setAnimationsEnabled:NO];
[collectionView performBatchUpdates:^{
[collectionView reloadData];
} completion:^(BOOL finished) {
[UIView setAnimationsEnabled:YES];
}];
方法二:
[UIView animateWithDuration:0 animations:^{
[collectionView performBatchUpdates:^{
[collectionView reloadData];
} completion:nil];
}];
注意:performBatchUpdates 这个方法是collectionView原来有数据的时候,上拉刷新才能用,第一次 reloaData 就调用这个方法,会崩溃的呦 QAQ
方法三:
NSMutableArray*indexPaths = [[NSMutableArray alloc] init];
for ( inti =0; i < model.mediumArr.count; i ++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: self.dataSource.count+ i in Section: 0];
[indexPaths addObject: indexPath];
}
[self.dataSource addObjectsFromArray: model.mediumArr];
[self.collectionView insertItemsAtIndexPaths: indexPaths];
[UIView performWithoutAnimation:^{
[self.collectionView reloadItemsAtIndexPaths: indexPaths];
}];
注:model.mediumArr为加载进来的新数据源,也就是上啦加载出来的数据(数组)
具体想用哪个方法,自己试试看看拿个更好一些,后面找到更好的方法,会持续更新
9、图片填充方式:
1、UIViewContentModeScaleAspectFit, //这个图片都会在view里面显示,并且比例不变 这就是说 如果图片和view的比例不一样 就会有留白
2、UIViewContentModeScaleAspectFill, // 这是整个view会被图片填满,图片比例不变 ,这样图片显示就会大于view
3、Scale to Fill: 缩放图片,使图片充满容器。没有aspect,图片未必保持长宽比例协调,有可能会拉伸至变形。
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’
报错信息如下:
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'
(
0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
5 SwiftLive 0x00000001001a1e3c -[FLAttentionViewController collectionView:didSelectItemAtIndexPath:] + 476
6 UIKit 0x000000018cdb9ad4 <redacted> + 596
7 UIKit 0x000000018cdb9468 <redacted> + 596
8 UIKit 0x000000018cd34e84 <redacted> + 336
9 UIKit 0x000000018cd7f500 <redacted> + 60
10 UIKit 0x000000018cd34e84 <redacted> + 336
11 UIKit 0x000000018cd7f500 <redacted> + 60
12 UIKit 0x000000018cd34e84 <redacted> + 336
13 UIKit 0x000000018cd7f500 <redacted> + 60
14 UIKit 0x000000018d166c90 <redacted> + 4484
15 UIKit 0x000000018d162d28 <redacted> + 1164
16 UIKit 0x000000018d162848 <redacted> + 408
17 UIKit 0x000000018d161b04 <redacted> + 268
18 UIKit 0x000000018cbd0a44 <redacted> + 2960
19 UIKit 0x000000018cba152c <redacted> + 340
20 UIKit 0x000000018d38ea54 <redacted> + 2736
21 UIKit 0x000000018d3884bc <redacted> + 784
22 CoreFoundation 0x0000000186cf4278 <redacted> + 24
23 CoreFoundation 0x0000000186cf3bc0 <redacted> + 524
24 CoreFoundation 0x0000000186cf17c0 <redacted> + 804
25 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
26 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
27 UIKit 0x000000018cc0c2fc <redacted> + 684
28 UIKit 0x000000018cc07034 UIApplicationMain + 208
29 SwiftLive 0x000000010037b6d0 main + 312
30 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
)
刚一开始看,以为是数据解析错误,但是明明是看着打印出的数据解析的,没有问题啊,郁闷的宝宝又去找师傅,师父说,肯定是你没字典转模型啊
确实,后台返的数组里面嵌套有字典,然后忘了写:
- (void)setValue:(id)value forKey:(NSString *)key
{
if ([key isEqualToString:@"live_info"])
{
[super setValue:value forKey:key];
}else
{
NSString *string = [NSString stringWithFormat:@"%@", value];
[super setValue:string forKey:key];
}
}
师父果然腻害,笨笨的我,总是丢三落四
11、大家新年快乐,今天继续上班,遇到了一个小小的问题:
*** -[__NSArrayM insertObject
]: object cannot be nil
2018-01-02 14:43:32.923 SwiftLive[1046:427525] <Unknown>: [BLYLog] Trapped uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
(
0 CoreFoundation 0x0000000181f2aff8 <redacted> + 148
1 libobjc.A.dylib 0x000000018098c538 objc_exception_throw + 56
2 CoreFoundation 0x0000000181e0c898 CFStringConvertNSStringEncodingToEncoding + 0
3 SwiftLive 0x000000010018e110 -[FLRefreshHeaderView imagesArr] + 336
4 SwiftLive 0x000000010018e684 -[FLRefreshHeaderView setRefreshState:] + 60
5 SwiftLive 0x000000010018da74 -[FLRefreshHeaderView refreshView] + 792
6 SwiftLive 0x000000010018f178 -[FLRefreshHeaderView setState:] + 1516
7 SwiftLive 0x00000001007c1aa0 -[MJRefreshComponent initWithFrame:] + 200
8 SwiftLive 0x000000010018d700 -[FLRefreshHeaderView init] + 76
9 SwiftLive 0x00000001007c524c +[MJRefreshHeader headerWithRefreshingTarget:refreshingAction:] + 92
10 SwiftLive 0x000000010021bd20 -[FLLiveListViewController setUpRefreshView] + 88
11 SwiftLive 0x000000010021bb40 -[FLLiveListViewController viewDidLoad] + 876
12 UIKit 0x000000018805cb04 <redacted> + 1036
13 UIKit 0x000000018805c6e0 <redacted> + 28
14 SwiftLive 0x000000010012b0ec -[FLHomeViewController collectionView:cellForItemAtIndexPath:] + 436
15 UIKit 0x00000001889564a0 <redacted> + 448
16 UIKit 0x00000001880bd3f0 <redacted> + 3820
17 UIKit 0x00000001880b8018 <redacted> + 300
18 UIKit 0x0000000188059cc0 <redacted> + 1200
19 QuartzCore 0x000000018524a274 <redacted> + 148
20 QuartzCore 0x000000018523ede8 <redacted> + 292
21 QuartzCore 0x000000018523eca8 <redacted> + 32
22 QuartzCore 0x00000001851ba34c <redacted> + 252
23 QuartzCore 0x00000001851e13ac <redacted> + 504
24 UIKit 0x00000001882f4840 <redacted> + 140
25 CoreFoundation 0x0000000181ed930c <redacted> + 20
26 CoreFoundation 0x0000000181ed8b28 <redacted> + 288
27 CoreFoundation 0x0000000181ed6998 <redacted> + 728
28 CoreFoundation 0x0000000181e06da4 CFRunLoopRunSpecific + 424
29 GraphicsServices 0x0000000183871074 GSEventRunModal + 100
30 UIKit 0x00000001880c1c9c UIApplicationMain + 208
31 SwiftLive 0x000000010044771c main + 312
32 libdyld.dylib 0x0000000180e1559c <redacted> + 4
)
这个出错的原因主要是,我们的一个帧动画需要替换,UI直接用我原来的图的名称命名的,便于我替换,不过帧的多少是不一样的,我把图片直接拉进去,代码里面的帧数改了,多余的帧的图片却忘记拉进项目,找不到对应的图,自然崩溃
12、-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000643
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'
(
0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
5 UIKit 0x000000018cbab7bc <redacted> + 108
6 UIKit 0x000000018cbab6b4 <redacted> + 128
7 UIKit 0x000000018cca1afc <redacted> + 96
8 UIKit 0x000000018cca18f0 <redacted> + 52
9 UIKit 0x000000018cca1458 <redacted> + 488
10 UIKit 0x000000018d4f3b78 <redacted> + 76
11 UIKit 0x000000018d4f289c <redacted> + 192
12 UIKit 0x000000018d4f2be4 <redacted> + 632
13 UIKit 0x000000018d4f2b6c <redacted> + 512
14 UIKit 0x000000018d4f2b6c <redacted> + 512
15 UIKit 0x000000018d4f2b6c <redacted> + 512
16 UIKit 0x000000018d4f2b6c <redacted> + 512
17 UIKit 0x000000018d4f2b6c <redacted> + 512
18 UIKit 0x000000018d4f2b6c <redacted> + 512
19 Foundation 0x0000000187775480 <redacted> + 168
20 UIKit 0x000000018d4f338c <redacted> + 84
21 UIKit 0x000000018d4f254c <redacted> + 136
22 UIKit 0x000000018d4f2f94 <redacted> + 164
23 UIKit 0x000000018d4f3f00 <redacted> + 364
24 UIKit 0x000000018ce9add4 <redacted> + 180
25 UIKit 0x000000018cb9e220 <redacted> + 1196
26 QuartzCore 0x000000018a05e188 <redacted> + 148
27 QuartzCore 0x000000018a052e64 <redacted> + 292
28 QuartzCore 0x000000018a052d24 <redacted> + 32
29 QuartzCore 0x0000000189fcf7ec <redacted> + 252
30 QuartzCore 0x0000000189ff6c58 <redacted> + 512
31 QuartzCore 0x0000000189ff7678 <redacted> + 120
32 CoreFoundation 0x0000000186cf37dc <redacted> + 32
33 CoreFoundation 0x0000000186cf140c <redacted> + 372
34 CoreFoundation 0x0000000186cf189c <redacted> + 1024
35 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
36 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
37 UIKit 0x000000018cc0c2fc <redacted> + 684
38 UIKit 0x000000018cc07034 UIApplicationMain + 208
39 SwiftLive 0x00000001003f7454 main + 312
40 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
)
每次从后台拿到值的时候,总忘判断后天传过来的值的类型,呢,又出错了,后台的给我的是长整型的变量,我赋值给了string类型。
13、the view returned from -collectionView
atIndexPath (UICollectionElementKindSectionHeader, {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind
forIndexPath: or is nil ((null))

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))'
(
0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
2 CoreFoundation 0x0000000186d46094 <redacted> + 0
3 Foundation 0x00000001877d379c <redacted> + 112
4 UIKit 0x000000018cd24044 <redacted> + 932
5 UIKit 0x000000018cc02678 <redacted> + 3868
6 UIKit 0x000000018cbfd0a4 <redacted> + 288
7 UIKit 0x000000018cb9e220 <redacted> + 1196
8 QuartzCore 0x000000018a05e188 <redacted> + 148
9 QuartzCore 0x000000018a052e64 <redacted> + 292
10 QuartzCore 0x000000018a052d24 <redacted> + 32
11 QuartzCore 0x0000000189fcf7ec <redacted> + 252
12 QuartzCore 0x0000000189ff6c58 <redacted> + 512
13 QuartzCore 0x0000000189ff7678 <redacted> + 120
14 CoreFoundation 0x0000000186cf37dc <redacted> + 32
15 CoreFoundation 0x0000000186cf140c <redacted> + 372
16 CoreFoundation 0x0000000186cf189c <redacted> + 1024
17 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
18 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
19 UIKit 0x000000018cc0c2fc <redacted> + 684
20 UIKit 0x000000018cc07034 UIApplicationMain + 208
21 SwiftLive 0x0000000100397478 main + 312
22 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
)
这个不是太确定,应该是要判断collectionView的header的section要确定下来,不能直接返回nil?有大神看到了帮忙解答下,蟹蟹。
14、**-[__NSSingleObjectArrayI objectForKey:]: unrecognized selector sent to instance 0x174011cd0**
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'
(
0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
5 Foundation 0x00000001877ea800 <redacted> + 212
6 SwiftLive 0x000000010036ac88 -[FLDiscoveryViewController dealRequestDataErrorWithOffset:] + 1092
7 SwiftLive 0x000000010036a5c4 -[FLDiscoveryViewController refreshData] + 404
8 SwiftLive 0x00000001006eac0c __47-[MJRefreshComponent executeRefreshingCallback]_block_invoke + 372
9 libdispatch.dylib 0x0000000101f1925c _dispatch_call_block_and_release + 24
10 libdispatch.dylib 0x0000000101f1921c _dispatch_client_callout + 16
11 libdispatch.dylib 0x0000000101f1e284 _dispatch_main_queue_callback_4CF + 1200
12 CoreFoundation 0x0000000186cf3f2c <redacted> + 12
13 CoreFoundation 0x0000000186cf1b18 <redacted> + 1660
14 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
15 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
16 UIKit 0x000000018cc0c2fc <redacted> + 684
17 UIKit 0x000000018cc07034 UIApplicationMain + 208
18 SwiftLive 0x000000010036f4a0 main + 312
19 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
)
这里就狠坑啦,主要还是窝是个小白,应该是字典转模型的,但是我取出来的是数组,而不是字段,根据打印,一看就是数组,怎么会不蹦捏!
字典:
{
avatar = "http://tx-upload.hk.ufileos.com/c229b79525a8a1e276d8e7c6817aab26.jpg";
"avatar_small" = "http://tx-upload.hk.ufileos.com/cca6661843afcd4953539a0dc220da50.jpg";
country = "";
"create_time" = 1514957449;
"current_count" = 0;
"end_time" = 0;
gender = 0;
"great_sort" = 0;
"hls_endpoint" = "http://hls.ylive.avazuinc.com:9090/hls/av3598/index.m3u8";
"hot_sort" = 0;
"like_sort" = 0;
"live_id" = 3598;
"live_pic" = "";
"liver_exp" = 208080;
"liver_grade" = 4;
"liver_next_exp" = 319300;
"new_sort" = 0;
nick = test123;
"people_count" = 300;
signature = "";
status = 2;
"streaming_endpoint" = "rtmp://source.publish.olivestream.tv/live/av3598";
title = "test123 on live";
uid = 828;
"update_time" = 1514957449;
"viewing_endpoint" = "http://rtmp.pull.olivestream.tv/live/av3598.flv";
}
数组:
(
{
avatar = "http://tx-upload.hk.ufileos.com/c229b79525a8a1e276d8e7c6817aab26.jpg";
"avatar_small" = "http://tx-upload.hk.ufileos.com/cca6661843afcd4953539a0dc220da50.jpg";
country = "";
"create_time" = 1514957449;
"current_count" = 0;
"end_time" = 0;
gender = 0;
"great_sort" = 0;
"hls_endpoint" = "http://hls.ylive.avazuinc.com:9090/hls/av3598/index.m3u8";
"hot_sort" = 0;
"like_sort" = 0;
"live_id" = 3598;
"live_pic" = "";
"liver_exp" = 208080;
"liver_grade" = 4;
"liver_next_exp" = 319300;
"new_sort" = 0;
nick = test123;
"people_count" = 300;
signature = "";
status = 2;
"streaming_endpoint" = "rtmp://source.publish.olivestream.tv/live/av3598";
title = "test123 on live";
uid = 828;
"update_time" = 1514957449;
"viewing_endpoint" = "http://rtmp.pull.olivestream.tv/live/av3598.flv";
}
)
15、网络状态不好的时候,明明设置了刷新超时,却明显超过了自己设置的超时时间,还在加载QAQ
原来代码如下:
感谢师父告诉我,这样是不对滴,
timeoutInterval 已经没有了作用。不管是同步还是异步。
这个问题只有在3.0以及之后的os中才有的,而且只有在当调用了setHTTPBody之后才会出现timeout失效。这个是苹果公司对URL Loading System的在iOS3.0中的一个改动,所有要改代码:
[request setTimeoutInterval:10.0f];
改成
[self.manager.requestSerializer setTimeoutInterval:10.0f];
感谢师父!
16、-[__NSCFNumber boundingRectWithSizeattributes
]: unrecognized selector sent to instance 0xb000000000d33a13
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'
(
0 CoreFoundation 0x0000000186d461d8 <redacted> + 148
1 libobjc.A.dylib 0x000000018578055c objc_exception_throw + 56
2 CoreFoundation 0x0000000186d4d278 <redacted> + 0
3 CoreFoundation 0x0000000186d4a278 <redacted> + 916
4 CoreFoundation 0x0000000186c4459c _CF_forwarding_prep_0 + 92
5 SwiftLive 0x000000010023cb50 -[FLChatRoomInfoView stringRect:fontSize:constraintWidth:constraintHeight:] + 288
6 SwiftLive 0x00000001002354b0 -[FLChatRoomInfoView updateUIWithAnchor:liveRoomInfo:isFollow:] + 2736
7 SwiftLive 0x00000001001e1cd0 -[FLLiveMainInterfaceViewController setupContentView] + 3844
8 SwiftLive 0x00000001001dfe60 -[FLLiveMainInterfaceViewController setupUI] + 2708
9 SwiftLive 0x00000001001d8be0 -[FLLiveMainInterfaceViewController viewDidLoad] + 372
10 UIKit 0x000000018cba10b0 <redacted> + 1056
11 UIKit 0x000000018cbb8c44 <redacted> + 132
12 UIKit 0x000000018cd41190 <redacted> + 1136
13 UIKit 0x000000018cc59858 <redacted> + 676
14 UIKit 0x000000018cc594c0 <redacted> + 64
15 UIKit 0x000000018cc59424 <redacted> + 188
16 UIKit 0x000000018cb9e220 <redacted> + 1196
17 QuartzCore 0x000000018a05e188 <redacted> + 148
18 QuartzCore 0x000000018a052e64 <redacted> + 292
19 QuartzCore 0x000000018a052d24 <redacted> + 32
20 QuartzCore 0x0000000189fcf7ec <redacted> + 252
21 QuartzCore 0x0000000189ff6c58 <redacted> + 512
22 QuartzCore 0x0000000189ff7678 <redacted> + 120
23 CoreFoundation 0x0000000186cf37dc <redacted> + 32
24 CoreFoundation 0x0000000186cf140c <redacted> + 372
25 CoreFoundation 0x0000000186cf189c <redacted> + 1024
26 CoreFoundation 0x0000000186c20048 CFRunLoopRunSpecific + 444
27 GraphicsServices 0x00000001886a6198 GSEventRunModal + 180
28 UIKit 0x000000018cc0c2fc <redacted> + 684
29 UIKit 0x000000018cc07034 UIApplicationMain + 208
30 SwiftLive 0x000000010038e380 main + 312
31 libdyld.dylib 0x0000000185c045b8 <redacted> + 4
)
boundingRectWithSizeattributes
是计算字符串宽度的方法,而后台传过来的是nsnumber类型的,所以出错了,你没看错,我每天都在出错中度过
17、在 UIScrollView上面添加了一个View,点击View的时候,页面上滑了一下,测试过来提bug,emmmm,可是宝宝看了层级关系,没有可点击的东西啊,QAQ
师父快来救我:
关于scrollView点击状态栏列表回到顶部的说明,想要禁用掉此功能将scrollsToTop属性设置为NO即可。
18、去除cell的点击后的选中背景:
方法一:自定义cell里面:
- (void)awakeFromNib {
[super awakeFromNib];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
方法二: 设置tableView的allowsSelection属性 注意:属性为NO的时候 tableView的代理方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 就不会执行 ,所以如果需要有cell点击事件的 不要用此方法
tableView.allowsSelection = NO;
方法三:更改cell属性selectedBackgroundView 的背景色
我们选中cell时有灰色效果就是因为selectedBackgroundView这个家伙,所以,我们可以通过设置改View的背景色来改变选中颜色
self.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
self.selectedBackgroundView.backgroundColor = [UIColor redColor];
注意点:
1, 在storyboard设置tableView属性的时候 如果这样设置 selection: NoSelection
会导致点击cell的时候没反应 不会调用 didSelectRowAtIndexPath 方法
要想有点击方法应设置成 selection: SingleSelection
19、-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000033
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'
(
0 CoreFoundation 0x00000001818a2ff8 <redacted> + 148
1 libobjc.A.dylib 0x0000000180304538 objc_exception_throw + 56
2 CoreFoundation 0x00000001818a9ef4 <redacted> + 0
3 CoreFoundation 0x00000001818a6f54 <redacted> + 916
4 CoreFoundation 0x00000001817a2d4c _CF_forwarding_prep_0 + 92
5 UIKit 0x00000001879de58c <redacted> + 108
6 UIKit 0x00000001879de484 <redacted> + 124
7 UIKit 0x0000000187ad29c0 <redacted> + 272
8 UIKit 0x0000000187ad2704 <redacted> + 52
9 UIKit 0x0000000187ad2230 <redacted> + 488
10 UIKit 0x0000000188335ca0 <redacted> + 112
11 UIKit 0x000000018833492c <redacted> + 192
12 UIKit 0x0000000188334c74 <redacted> + 624
13 UIKit 0x0000000188334bfc <redacted> + 504
14 UIKit 0x0000000188334bfc <redacted> + 504
15 UIKit 0x0000000188334bfc <redacted> + 504
16 UIKit 0x0000000188334bfc <redacted> + 504
17 UIKit 0x0000000188334bfc <redacted> + 504
18 UIKit 0x0000000188334bfc <redacted> + 504
19 UIKit 0x0000000188334bfc <redacted> + 504
20 Foundation 0x00000001822dca7c <redacted> + 168
21 UIKit 0x0000000188335410 <redacted> + 88
22 UIKit 0x0000000188334340 <redacted> + 116
23 UIKit 0x0000000188335024 <redacted> + 164
24 UIKit 0x0000000188336070 <redacted> + 432
25 UIKit 0x00000001879e596c <redacted> + 892
26 SwiftLive 0x000000010022f88c __69-[FLLiveMainInterfaceViewController showDialogWithUserInfo:withType:]_block_invoke.1225 + 84
27 UIKit 0x0000000187a093dc <redacted> + 644
28 UIKit 0x0000000187b4da24 <redacted> + 100
29 SwiftLive 0x000000010022f518 -[FLLiveMainInterfaceViewController showDialogWithUserInfo:withType:] + 620
30 SwiftLive 0x0000000100234a58 -[FLLiveMainInterfaceViewController chatMessageShowUserDetail:withType:] + 84
31 SwiftLive 0x00000001000f3cb4 -[FLChatMessageView getUserDetails:] + 1920
32 SwiftLive 0x00000001000f3ef0 -[FLChatMessageView showUserInfo:] + 444
33 UIKit 0x0000000187fa5d38 <redacted> + 64
34 UIKit 0x0000000187fa956c <redacted> + 124
35 UIKit 0x0000000187b63470 <redacted> + 252
36 UIKit 0x0000000187a05380 <redacted> + 720
37 UIKit 0x0000000187f99810 <redacted> + 988
38 UIKit 0x0000000187f993e0 <redacted> + 404
39 UIKit 0x0000000187f9868c <redacted> + 268
40 UIKit 0x0000000187a0370c <redacted> + 3164
41 UIKit 0x00000001879d433c <redacted> + 340
42 UIKit 0x00000001881ce014 <redacted> + 2400
43 UIKit 0x00000001881c8770 <redacted> + 4268
44 UIKit 0x00000001881c8b9c <redacted> + 148
45 CoreFoundation 0x000000018185142c <redacted> + 24
46 CoreFoundation 0x0000000181850d9c <redacted> + 540
47 CoreFoundation 0x000000018184e9a8 <redacted> + 744
48 CoreFoundation 0x000000018177eda4 CFRunLoopRunSpecific + 424
49 GraphicsServices 0x00000001831e8074 GSEventRunModal + 100
50 UIKit 0x0000000187a39058 UIApplicationMain + 208
51 SwiftLive 0x00000001003dc848 main + 312
52 libdyld.dylib 0x000000018078d59c <redacted> + 4
)
这个错误可能是因为 把整形变量直接赋值给NSString类型变量,没有进行转化。
我错在了,拿到后台的数据是Int类型,赋值给了我自己定义的String类型QAQ
还没有评论,来说两句吧...