这个问题在这里已有答案:
首先,大家新年快乐,并提前感谢您的回复!如果之前已经问过,我很感激你可以提供链接 . 过去几天一直在努力挖掘,没有人帮助过 .
我需要你的帮助,最近一直在做.net核心的东西,这次我用XCode再次开始使用XCode(和生锈) . 我用以下步骤创建了一个简单的Objective C项目(我之前在旧版本的Xcode上做过) :
-
删除了默认的故事板
-
删除了启动画面
-
修改了上述步骤1和2的plist文件
-
创建了一个新的"Cocoa Touch Class",其子类为UIViewController和XIB(名为vcMain)
-
修改了appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *mainView = [[UIViewController alloc] initWithNibName:@"vcMain" bundle:nil];
self.window.rootViewController = mainView;
[self.window makeKeyAndVisible];
return YES;
}
- 修改了vcMain.h
7.修改了vcMain.m
- 当我运行它时,我得到下面的错误(在链接出口和在XIB中接收动作之前我没有得到) .
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnClient.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010475f12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000108cfaf41 objc_exception_throw + 48
2 CoreFoundation 0x000000010475f079 -[NSException raise] + 9
3 Foundation 0x00000001053b5a63 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x0000000106cf5117 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x0000000106fe6c2d -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001047023cd -[NSArray makeObjectsPerformSelector:] + 317
7 UIKit 0x0000000106fe55e3 -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x0000000106cfc3ff -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKit 0x0000000106cfcd2b -[UIViewController loadView] + 177
10 UIKit 0x0000000106cfd05c -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x0000000106cfd8b9 -[UIViewController view] + 27
12 UIKit 0x0000000106bc87cf -[UIWindow addRootViewControllerViewIfPossible] + 122
13 UIKit 0x0000000106bc8ed7 -[UIWindow _setHidden:forced:] + 294
14 UIKit 0x0000000106bdbe54 -[UIWindow makeKeyAndVisible] + 42
15 [app name] 0x00000001040b7c8f -[AppDelegate application:didFinishLaunchingWithOptions:] + 639
16 UIKit 0x0000000106b4cbca -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
17 UIKit 0x0000000106b4e648 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4113
18 UIKit 0x0000000106b53aeb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1720
19 UIKit 0x0000000106f1d6f8 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 924
20 UIKit 0x00000001072f34c8 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
21 UIKit 0x0000000106f1d2f1 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 249
22 UIKit 0x0000000106f1db6b -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 696
23 UIKit 0x000000010789ba69 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 262
24 UIKit 0x000000010789b922 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 444
25 UIKit 0x00000001075789c8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
26 UIKit 0x0000000107777b06 _performActionsWithDelayForTransitionContext + 100
27 UIKit 0x000000010757888b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 231
28 UIKit 0x00000001072f2b25 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
29 UIKit 0x0000000106b5236a -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 523
30 UIKit 0x000000010712d605 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 369
31 FrontBoardServices 0x000000011038dcc0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 338
32 FrontBoardServices 0x00000001103967b5 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 235
33 libdispatch.dylib 0x000000010a8a533d _dispatch_client_callout + 8
34 libdispatch.dylib 0x000000010a8aa9f3 _dispatch_block_invoke_direct + 592
35 FrontBoardServices 0x00000001103c2498 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
36 FrontBoardServices 0x00000001103c214e -[FBSSerialQueue _performNext] + 464
37 FrontBoardServices 0x00000001103c26bd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
38 CoreFoundation 0x0000000104702101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
39 CoreFoundation 0x00000001047a1f71 __CFRunLoopDoSource0 + 81
40 CoreFoundation 0x00000001046e6a19 __CFRunLoopDoSources0 + 185
41 CoreFoundation 0x00000001046e5fff __CFRunLoopRun + 1279
42 CoreFoundation 0x00000001046e5889 CFRunLoopRunSpecific + 409
43 GraphicsServices 0x000000010c9ae9c6 GSEventRunModal + 62
44 UIKit 0x0000000106b555d6 UIApplicationMain + 159
45 [app name] 0x00000001040b82bf main + 111
46 libdyld.dylib 0x000000010a921d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I solved this by doing the changes on the AppDelegate.M
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
vcMain *mainView = [[vcMain alloc] initWithNibName:@"vcMain" bundle:nil];
/*
UIViewController *mainView = [[UIViewController alloc] initWithNibName:@"vcMain" bundle:nil];
*/
self.window.rootViewController = mainView;
[self.window makeKeyAndVisible];
return YES;
}
1 回答
尝试从Attribute Inspector中删除btnClient出口并重新分配插座 .