2011-10-10 74 views
0

我是編程新手,現在我正在編寫6個視圖的應用程序。 我的程序開始不是真的,我只看到背景--default.png - 然後prpgramm崩潰,但我看到默認圖像。 另外我有問題了解我收到的警告,它就像一種新的語言。 如果你知道一本書或頁面如何將這種警告解碼這將是非常有益的太Objective-C警告 - 我錯過了什麼或錯在哪裏?

2011-10-10 17:22:16.249 TestTest[2642:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "TestTestViewController" nib but the view outlet was not set.' 

(
0 CoreFoundation      0x00ec25a9 __exceptionPreprocess + 185 
1 libobjc.A.dylib      0x01016313 objc_exception_throw + 44 
2 CoreFoundation      0x00e7aef8 +[NSExceptionraise:format:arguments:] + 136 
3 CoreFoundation      0x00e7ae6a +[NSException raise:format:] + 58 
4 UIKit        0x0036b709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295 
5 UIKit        0x00369134 -[UIViewController loadView] + 120 
6 UIKit        0x0036900e -[UIViewController view] + 56 
7 UIKit        0x002dcd42 -[UIWindow addRootViewControllerViewIfPossible] + 51 
8 UIKit        0x002dc22d -[UIWindow _setHidden:forced:] + 303 
9 UIKit        0x002dc01d -[UIWindow _orderFrontWithoutMakingKey] + 50 
10 UIKit        0x002dacd1 -[UIWindow makeKeyAndVisible] + 39 
11 TestTest       0x000026be -[TestTestAppDelegate application:didFinishLaunchingWithOptions:] + 135 
12 UIKit        0x002b9c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 
13 UIKit        0x002bbd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439 
14 UIKit        0x002c6617 -[UIApplication handleEvent:withNewEvent:] + 1533 
15 UIKit        0x002beabf -[UIApplication sendEvent:] + 71 
16 UIKit        0x002c3f2e _UIApplicationHandleEvent + 7576 
17 GraphicsServices     0x0181a992 PurpleEventCallback + 1550 
18 CoreFoundation      0x00ea3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
19 CoreFoundation      0x00e03cf7 __CFRunLoopDoSource1 + 215 
20 CoreFoundation      0x00e00f83 __CFRunLoopRun + 979 
21 CoreFoundation      0x00e00840 CFRunLoopRunSpecific + 208 
22 CoreFoundation      0x00e00761 CFRunLoopRunInMode + 97 
23 UIKit        0x002bb7d2 -[UIApplication _run] + 623 
24 UIKit        0x002c7c93 UIApplicationMain + 1160 
25 TestTest       0x00002614 main + 102 
26 TestTest       0x000025a5 start + 53 
27 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 
Program received signal: 「SIGABRT」. 
kill 
quit 

The Debugger has exited with status 0.(gdb) 

預先感謝您

回答

1

你已經在NIB中創建了一個視圖控制器,但是你沒有給它一個視圖。您應該通過將視圖放入NIB並從視圖控制器向視圖進行控制單擊,然後從彈出窗口中選擇視圖插座 - 即在界面設計器中連接事物的常規方式。

您看到的錯誤是UIViewController故意引發的異常,因爲它不知道如何在沒有視圖的情況下繼續。下面的東西是堆棧跟蹤;如果問題出現在你自己的代碼中,你可以使用它來查看調用模式將你帶入無效狀態。由於它是一些內部的東西,其邏輯結構是記錄的,但內部實現是私人的,你應該忽略它。

+0

有時我會對結構感到困惑,因爲我不知道在哪些方法中我必須編寫代碼。我自己學習Objective-C,我的講座沒有用處。你怎麼知道你會提出所有的和哪本書? – Studie

+2

蘋果的文檔相當不錯。訣竅是它沒有像書本那樣組織起來。這就像一堆散落的章節。在這種情況下,你應該閱讀視圖控制器編程指南。一般來看看入門文檔。這會給你鏈接到幾個你可能需要開始的「章節」。 – morningstar

+0

@morningstar謝謝你的建議 – Studie

1

看你的崩潰報告的第一線,原因崩潰是很明顯:

加載了「TestTestViewController」筆尖,但未設置視圖插口。

0

回過頭來看看您使用的任何文本,瞭解如何創建視圖控制器和XIB文件並找出錯過的步驟。