汇总一些遇到的BUG
用AutoLayout有时候会出现:
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x17ef4e10 V:[UIView:0x17ee9e00]-(0)-| (Names: '|':UIView:0x17ef3e10 )>",
"<NSLayoutConstraint:0x17ef4e70 V:|-(0)-[UIView:0x17ee9e00] (Names: '|':UIView:0x17ef3e10 )>",
"<NSLayoutConstraint:0x17dc8650 'UIView-Encapsulated-Layout-Height' V:[UIView:0x17ef3e10(455)]>",
"<NSAutoresizingMaskLayoutConstraint:0x17dc86b0 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UIView:0x17ef3e10] (Names: '|':UIViewControllerWrapperView:0x17d7ac80 )>",
"<NSAutoresizingMaskLayoutConstraint:0x17d90d50 h=--& v=--& UIView:0x17ee9e00.midY == + 184>"
)
错误原因可能是:在添加约束的时候,比如说 水平方向的约束leading trailing和 weight 冲突了系统会帮我们去掉宽度的限制
解决方法: 重新添加约束,选择性的不添加宽度<根据情况不添加一些约束>
JSON解析数据 for循环嵌套错误
-[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7fff32fabdc0
JSON解析数据,方式不对
-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7f85d4110700
原因: 解析字典时,定义的是数组;解析数组时,定义的是字典
setValue:ForUnderfinedKey:]:this class is not key value coding
原因:连线出问题了
-[ViewController up]: unrecognized selector sent to instance 0x8c50af0
原因:某个对象没有实现某个方法
"_SCNetworkReachabilityCreateWithName", referenced from:
原因:静态库中依赖的一些框架没有导入.如果静态库中用到了框架就必须导入
"std::terminate()", referenced from:
但凡看到错误提示中提示两个冒号,表示C++代码, 默认情况下Xcode创建的工程是不支持C++.
如何解决: 将工程中任意一个文件的后缀改为.MM即可
.c --> C代码
.cpp --> C++代码
.m --> C代码 + OC代码
.MM -->C代码 + OC代码 + C++代码
Undefined symbols for architecture x86_64:
这个错误, 一般是指用到的三方框架不支持64位手机
解决方式: 打开工程 --> Build Settings --> All --> Architectures --> Debug\Release --> Other -->修改为 $(ARCHS_STANDARD_32_BIT)