简体   繁体   English

创建新视图后崩溃的iOS应用

[英]Crashing iOS app after creating a new view

I'm just starting to learn creating iOS apps and so I'm just a noob in it. 我刚刚开始学习如何创建iOS应用,所以我只是其中的菜鸟。 Especially because of the different approach it has on handling navigation and interaction between UI and Code. 特别是由于它在处理导航和UI与代码之间的交互方面具有不同的方法。 :) :)

Ok I'm using xCode 5 with SDK version 7. I created a single view application and it gave me a .storyboard file which I guess replaces the .xib which used to be there when I watch tutorial videos. 好吧我使用的Xcode 5 SDK版本7.我创建了一个单一视图的应用程序,它给了我一个.storyboard我猜替换文件.xib这曾经是那里当我观看教程视频。

So I designed a simple UI as the main view and now I want to have another view as the landing view. 因此,我设计了一个简单的UI作为main视图,现在我想将另一个视图作为landing视图。 So it should come in before the main view. 因此,它应该出现在main视图之前。 I went ahead and from New File... I created an Objective-C class which is a subclass of UIViewController and named it Detail . 我继续并从New File...创建了一个Objective-C类,它是UIViewController的子类,并将其命名为Detail Surprisingly it gave me a .xib file again. 令人惊讶的是,它又给了我一个.xib文件。 Fair enough. 很公平。 Then I just put a simple input in the UI to just preview it. 然后,我只在UI中输入一个简单的输入即可预览它。

Then from Project Settings, in the General tab, I changed the Main Interface to match the new .xib file I created. 然后从“项目设置”的“常规”选项卡中,更改了“ Main Interface以匹配我创建的新.xib文件。 But when I launched the application, it crashed and I don't know what the problem is. 但是,当我启动该应用程序时,它崩溃了,我不知道问题出在哪里。

Here is the stack trace: 这是堆栈跟踪:

2013-11-27 18:31:21.735 TestViewSwitching[10123:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8b35dc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0174c5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014bb8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x017dc6a1 -[NSException raise] + 17
    3   Foundation                          0x0117c9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x010e8cfb _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x010e8253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   Foundation                          0x0114a70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    7   UIKit                               0x004cba15 -[UIRuntimeOutletConnection connect] + 106
    8   libobjc.A.dylib                     0x014cd7d2 -[NSObject performSelector:] + 62
    9   CoreFoundation                      0x01747b6a -[NSArray makeObjectsPerformSelector:] + 314
    10  UIKit                               0x004ca56e -[UINib instantiateWithOwner:options:] + 1417
    11  UIKit                               0x004cc2fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
    12  UIKit                               0x002293bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58
    13  UIKit                               0x002296e9 -[UIApplication _loadMainInterfaceFile] + 245
    14  UIKit                               0x0022828f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
    15  UIKit                               0x0023c87c -[UIApplication handleEvent:withNewEvent:] + 3447
    16  UIKit                               0x0023cde9 -[UIApplication sendEvent:] + 85
    17  UIKit                               0x0022a025 _UIApplicationHandleEvent + 736
    18  GraphicsServices                    0x036df2f6 _PurpleEventCallback + 776
    19  GraphicsServices                    0x036dee01 PurpleEventCallback + 46
    20  CoreFoundation                      0x016c7d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    21  CoreFoundation                      0x016c7a9b __CFRunLoopDoSource1 + 523
    22  CoreFoundation                      0x016f277c __CFRunLoopRun + 2156
    23  CoreFoundation                      0x016f1ac3 CFRunLoopRunSpecific + 467
    24  CoreFoundation                      0x016f18db CFRunLoopRunInMode + 123
    25  UIKit                               0x00227add -[UIApplication _run] + 840
    26  UIKit                               0x00229d3b UIApplicationMain + 1225
    27  TestViewSwitching                   0x0000211d main + 141
    28  libdyld.dylib                       0x01d7670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This process in Android is pretty straight forward, but I don't know why Apple tries to make everything harder for developers. Android中的此过程非常简单,但是我不知道为什么Apple会尝试使开发人员更难。 They couldn't just set up a type which generates a new view ready to go? 他们不能只建立一个可以生成新视图的类型吗?

@Miro Markarian,您可以检查.xib文件中的视图出口。它可能已断开连接或损坏。通常是由于这个原因而引起的。请尝试将视图控制器视图的出口添加到.xib视图中。

主视图控制器的.xib上的视图出口未正确连接到其file owner

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

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