2017-04-07 80 views
1

在我的iOS应用程序中,我有一个带有2个textfields的初始viewcontroller用于登录。 如果我在调试模式下运行应用程序代码编译良好,我可以看到我在主要故事板上设置的初始viewcontroller。由于IBOutlet的原因,iOS应用程序在didFinishLaunchingWithOptions中崩溃

相反,如果我尝试运行代码版本该应用程序崩溃平静,没有设置插座。

2017-04-07 13:55:53.422 Sahin Fruit[40068:1230157] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fb5e2e0a450> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key emailTextField.' 

为了克服我尝试设置初始VC中的AppDelegate编程的问题,但没有结果,应用程序仍然崩溃。任何想法?

self.window = UIWindow(frame: UIScreen.main.bounds) 
    let initialViewController = UIStoryboard.viewControllerWithIdentifier(Main.loginVC.rawValue, storyBoardName: .Main) 
    self.window?.rootViewController = initialViewController 
    self.window?.makeKeyAndVisible() 

P.S:我关闭了Release中的优化,看看这样做是否也有帮助。

+1

问题的属性,检查一次'emailTextField'连接或不 –

+0

emailTextField确实连接,否则它将无法在debug =) –

+0

确保一次...... –

回答

0

你有你的代码删除,但仍连接在界面生成器

+0

看到这一次有问题'如果我尝试运行代码释放应用程序崩溃平静,出口没有设置'不在'emailTextField肯定连接,否则它不会在调试工作' –

1

这是因为你必须在故事板已复制的ViewController并赋予它不同类的旧插座。只需右击第一个方框中的ViewController顶部(忘记确切名称),然后您的额外插座将显示为yellow color triangle, just delete it,您的项目将生成良好。

enter image description here

0

检查您的网点引用您的故事板,其中一人可能是引用不存在在你的inital VC了