有没有人有任何想法,这是在扼杀我。从单视图应用程序模板创建应用程序,删除storyboard和ViewController.swift文件,然后添加一个名为MainViewController
的新视图控制器,其中包含 Xib 。
将Main Interface的项目设置从Main更改为MainViewController
并运行。
在以前的Xcode版本中,这样可以正常工作。现在无论我尝试什么,我都无法让它发挥作用。尝试在App Delegate中初始化视图控制器,但没有快乐,它只是崩溃了这个例外:
2014-11-22 11:14:48.084 TestApp[9781:422842] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x7fd510611320> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001025c9f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010410dbb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001025c9b79 -[NSException raise] + 9
3 Foundation 0x00000001029e17b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000102513e80 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010311ac7d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010311c722 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 160
7 UIKit 0x0000000102e54b11 -[UIApplication _loadMainNibFileNamed:bundle:] + 46
8 UIKit 0x0000000102e53c19 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1075
9 UIKit 0x0000000102e52bf2 -[UIApplication workspaceDidEndTransaction:] + 179
10 FrontBoardServices 0x0000000105cad2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
11 CoreFoundation 0x00000001024ff53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
12 CoreFoundation 0x00000001024f5285 __CFRunLoopDoBlocks + 341
13 CoreFoundation 0x00000001024f5045 __CFRunLoopRun + 2389
14 CoreFoundation 0x00000001024f4486 CFRunLoopRunSpecific + 470
15 UIKit 0x0000000102e52669 -[UIApplication _run] + 413
16 UIKit 0x0000000102e55420 UIApplicationMain + 1282
17 TestApp 0x00000001023e9cae top_level_code + 78
18 TestApp 0x00000001023e9cea main + 42
19 libdyld.dylib 0x00000001048e7145 start + 1
20 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:0)
您需要为主界面提供xib或storyboard文件。不是ViewController。
另外请确保您没有任何悬挂式插座。确保xib中的对象没有ViewController.h或ViewController.m中不存在的插座集