一、初始化ViewController出错
版本
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Xcode Version 8.2.1 (8C1002)
在用如下代码初始化ViewController时
storyboard.instantiateViewController
报出如下错误信息
Unknown class JWSwiftMineEditViewController in Interface Builder file.
Could not cast value of type 'UIViewController' (0x1b0d2ff50) to 'JWBizCardNew.JWSwiftMineEditViewController' (0x100dd1ab8).
原因相当奇葩,如图:
Module为None
这是StoryBoard上出错的ViewController的属性,我们可以看到这里的Module为None,这应该是Xcode的bug。
在Module栏里用鼠标左击一下,再按回车。会变成这个样子:
Module有值
这样,问题就解决了。
二、发http请求出错
版本
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Xcode Version 8.2.1 (8C1002)
Allow Arbitrary Loads已经设为YES了,发http请求还是报如下错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
试了半天,发现Allow Arbitrary Loads in Web Content与Allow Arbitrary Loads不能共存。把Allow Arbitrary Loads in Web Content删掉就好了。
三、运行时报错: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.
把子线程中针对UI的更新,放到主线程中执行即可。
网友评论