简体   繁体   English

更新到Swift 3.0和Xcode 8的黑屏模拟器

[英]Black screen simulator at update to Swift 3.0 and Xcode 8

I have updated from Xcode 7 to Xcode 8. I had a project on Swift 2.2 and it works well but when I have updated to Xcode 8 and Swift 3 I only can see a black screen on the simulator. 我已经从Xcode 7更新到Xcode 8.我在Swift 2.2上有一个项目,它运行良好但是当我更新到Xcode 8和Swift 3时,我只能在模拟器上看到黑屏。

I have tried using Clean and Clean Build Folder options but the black screen is still being shown. 我尝试过使用“清洁和清洁构建文件夹”选项,但仍然显示黑屏。 After that, Build option. 之后,构建选项。 Also, there is no errors on the console or in Xcode. 此外,控制台或Xcode中没有错误。

Did someone get the same error at updating to Swift 3.0? 有人在更新到Swift 3.0时遇到同样的错误吗? Or do you know something that I can check and could be the reason of my black screen? 或者你知道我可以查看的东西,可能是我黑屏的原因吗? I cannot found any similar behaviour on Internet when updating to the new Swift version. 在更新到新的Swift版本时,我在Internet上找不到任何类似的行为。

Thank you to @YashTamakuwala because he gave me the clue that made me get the solution. 感谢@YashTamakuwala,因为他给了我一些让我得到解决方案的线索。

I have referenced the Initial View Controller as normal and it was linked correctly because it was also connected on Identity Inspector . 我已正常引用Initial View Controller ,并且它已正确链接,因为它也在Identity Inspector上连接。

What I have to do is to remove the Initial View Controller mark and the navigation controller that was linked to the first View Controller. 我要做的是删除Initial View Controller标记和链接到第一个视图控制器的导航控制器。 Then, I have set the Initial View Controller mark again to the View Controller and go to Editor > Embed In > Navigation Controller . 然后,我再次将Initial View Controller标记设置到View Controller然后转到Editor > Embed In > Navigation Controller

After do that, the project is again being shown on the simulator, without black screens. 完成后,项目再次显示在模拟器上,没有黑屏。

In my case, I used xib only but got the same problem. 在我的情况下,我只使用xib但遇到了同样的问题。

Then I changed application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 然后我改变了application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool

to application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool

and it worked :D 它起作用了:D

Note: You shouldn't copy and paste. 注意:您不应复制和粘贴。 Should let Xcode suggest :) 应该让Xcode建议:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM