iOS 错误锦集
来源:互联网 发布:nessus windows 编辑:程序博客网 时间:2024/05/09 19:18
从今天开始,我打算把自己所有遇到的错误,无论大大小小,都保存下来,以供自己反思,少点粗心才能提高效率
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> + 1481 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 562 CoreFoundation 0x000000018cbbaf28 <redacted> + 03 Foundation 0x000000018d7ad378 <redacted> + 1284 Foundation 0x000000018d7ad0f8 <redacted> + 765 Foundation 0x000000018d5f9b48 <redacted> + 1326 Foundation 0x000000018d7abd80 <redacted> + 1127 UIKit 0x0000000192ce9eac <redacted> + 16928 QuartzCore 0x000000018feda274 <redacted> + 1489 UIKit 0x000000019333a234 <redacted> + 6410 QuartzCore 0x000000018fecede8 <redacted> + 29211 QuartzCore 0x000000018fececa8 <redacted> + 3212 QuartzCore 0x000000018fe4a34c <redacted> + 25213 QuartzCore 0x000000018fe713ac <redacted> + 50414 QuartzCore 0x000000018fe716d8 <redacted> + 24415 libsystem_pthread.dylib 0x000000018bc7be20 <redacted> + 57216 libsystem_pthread.dylib 0x000000018bc7bb48 <redacted> + 20017 libsystem_pthread.dylib 0x000000018bc7b1d8 _pthread_wqthread + 131218 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> + 1481 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 562 CoreFoundation 0x000000018cbbaeb4 <redacted> + 03 Foundation 0x000000018d653760 <redacted> + 1124 SwiftLive 0x00000001007c47d0 -[MASViewConstraint setSecondViewAttribute:] + 7725 SwiftLive 0x00000001007c5730 __40-[MASViewConstraint equalToWithRelation]_block_invoke + 17566 SwiftLive 0x00000001007be424 __24-[MASConstraint equalTo]_block_invoke + 1007 SwiftLive 0x000000010017741c __29-[FLGiftSendView configureUI]_block_invoke.66 + 5168 SwiftLive 0x00000001007cbfd8 -[UIView(MASAdditions) mas_makeConstraints:] + 1329 SwiftLive 0x0000000100175b7c -[FLGiftSendView configureUI] + 75210 SwiftLive 0x00000001001757c4 -[FLGiftSendView initWithFrame:] + 33211 SwiftLive 0x000000010045eb2c -[FLChooseGiftsView setupUI] + 368012 SwiftLive 0x000000010045dbb4 -[FLChooseGiftsView init] + 13613 SwiftLive 0x0000000100291570 -[FLLiveMainInterfaceViewController setupContentView] + 468014 SwiftLive 0x000000010028f3bc -[FLLiveMainInterfaceViewController setupUI] + 270815 SwiftLive 0x00000001002881e0 -[FLLiveMainInterfaceViewController viewDidLoad] + 34416 UIKit 0x0000000192cecb04 <redacted> + 103617 UIKit 0x0000000192d04590 <redacted> + 13218 UIKit 0x0000000192e88e18 <redacted> + 114419 UIKit 0x0000000192da37bc <redacted> + 67620 UIKit 0x0000000192da3424 <redacted> + 6421 UIKit 0x0000000192da3388 <redacted> + 18822 UIKit 0x0000000192ce9cc0 <redacted> + 120023 QuartzCore 0x000000018feda274 <redacted> + 14824 QuartzCore 0x000000018fecede8 <redacted> + 29225 QuartzCore 0x000000018fececa8 <redacted> + 3226 QuartzCore 0x000000018fe4a34c <redacted> + 25227 QuartzCore 0x000000018fe713ac <redacted> + 50428 QuartzCore 0x000000018fe71e78 <redacted> + 12029 CoreFoundation 0x000000018cb689a8 <redacted> + 3230 CoreFoundation 0x000000018cb66630 <redacted> + 37231 CoreFoundation 0x000000018cb66a7c <redacted> + 95632 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 42433 GraphicsServices 0x000000018e501074 GSEventRunModal + 10034 UIKit 0x0000000192d51c9c UIApplicationMain + 20835 SwiftLive 0x0000000100437dd8 main + 31236 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> + 1481 libobjc.A.dylib 0x000000018b61c538 objc_exception_throw + 562 CoreFoundation 0x000000018cbc1ef4 <redacted> + 03 CoreFoundation 0x000000018cbbef54 <redacted> + 9164 CoreFoundation 0x000000018cabad4c _CF_forwarding_prep_0 + 925 UIKit 0x0000000192cf66c8 <redacted> + 3126 SwiftLive 0x000000010014f574 -[FLGiftSendView tableView:didSelectRowAtIndexPath:] + 9007 UIKit 0x0000000192e17a9c <redacted> + 12008 UIKit 0x0000000192ec7820 <redacted> + 2689 UIKit 0x0000000192f79594 <redacted> + 29210 UIKit 0x0000000192f6b630 <redacted> + 52811 UIKit 0x0000000192cdf28c <redacted> + 13212 CoreFoundation 0x000000018cb689a8 <redacted> + 3213 CoreFoundation 0x000000018cb66630 <redacted> + 37214 CoreFoundation 0x000000018cb66a7c <redacted> + 95615 CoreFoundation 0x000000018ca96da4 CFRunLoopRunSpecific + 42416 GraphicsServices 0x000000018e501074 GSEventRunModal + 10017 UIKit 0x0000000192d51c9c UIApplicationMain + 20818 SwiftLive 0x000000010040ba24 main + 31219 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"]; }
阅读全文
0 0
- iOS 错误锦集
- IOS错误调试集
- iOS---错误合集
- iOS-错误集
- IOS常见错误合集
- ios 错误
- 关于iOS中的一些错误集
- iOS 打包上传 appStore 错误集
- IOS小知识点13之xcode常见错误问题锦集
- IOS 开发codesign错误
- ios 异常错误分析
- IOS autorelease 错误
- IOS错误分析
- EXC_BAD_ACCESS iOS内存错误
- ios推送常见错误
- ios错误码
- iOS编译错误
- IOS开发错误收集
- 三轴加速度传感器的计步测算法
- Nginx+php+http/https服务器配置
- EventBus的使用
- 面向对象编程 约瑟夫问题简要分析
- python numpy和list查询其中某个数的个数及定位
- iOS 错误锦集
- 《程序设计实践》【PDF】下载
- [分享]钛极OS(TiJOS)物联网操作系统介绍
- dd命令生成一个大文件
- 安卓通过app之间的跳转
- Hello World!
- C#学习笔记之——泛型(Generic)
- 搭建 Keepalived + Nginx + Tomcat 的高可用负载均衡架构
- enter切换文本框实现登陆功能