[英]Crashing iOS app after creating a new view
我剛剛開始學習如何創建iOS應用,所以我只是其中的菜鳥。 特別是由於它在處理導航和UI與代碼之間的交互方面具有不同的方法。 :)
好吧我使用的Xcode 5 SDK版本7.我創建了一個單一視圖的應用程序,它給了我一個.storyboard
我猜替換文件.xib
這曾經是那里當我觀看教程視頻。
因此,我設計了一個簡單的UI作為main
視圖,現在我想將另一個視圖作為landing
視圖。 因此,它應該出現在main
視圖之前。 我繼續並從New File...
創建了一個Objective-C類,它是UIViewController
的子類,並將其命名為Detail
。 令人驚訝的是,它又給了我一個.xib
文件。 很公平。 然后,我只在UI中輸入一個簡單的輸入即可預覽它。
然后從“項目設置”的“常規”選項卡中,更改了“ Main Interface
以匹配我創建的新.xib
文件。 但是,當我啟動該應用程序時,它崩潰了,我不知道問題出在哪里。
這是堆棧跟蹤:
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
Android中的此過程非常簡單,但是我不知道為什么Apple會嘗試使開發人員更難。 他們不能只建立一個可以生成新視圖的類型嗎?
@Miro Markarian,您可以檢查.xib文件中的視圖出口。它可能已斷開連接或損壞。通常是由於這個原因而引起的。請嘗試將視圖控制器視圖的出口添加到.xib視圖中。
主視圖控制器的.xib
上的視圖出口未正確連接到其file owner
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.