我正在尝试从Main.storyboard获得一个导航控制器,而不再使用rootviewcontroller的代码,我也使用segues而不是xib文件。请注意,我已设置视图插座,因此不是导致错误的问题。但是,当我运行应用程序时出现错误:
更新1:请仔细查看代码并指出我需要做出的任何更改。在我的Main.storyboard中,有一个NavigationController根视图连接到一个视图控制器,然后从那里连接到另一个视图控制器。
2014-09-14 17:43:38.391 SliderGalore Puzzle Game[5204:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "YgU-b0-wQK-view-Cu4-NM-jCd" nib but the view outlet was not set.'
*** First throw call stack:
(
0 CoreFoundation 0x017415e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c48b6 objc_exception_throw + 44
2 CoreFoundation 0x017413bb +[NSException raise:format:] + 139
3 UIKit 0x003456e6 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
4 UIKit 0x00345dad -[UIViewController loadView] + 302
5 UIKit 0x003460ae -[UIViewController loadViewIfRequired] + 78
6 UIKit 0x0036bb15 -[UINavigationController _layoutViewController:] + 39
7 UIKit 0x0036c02b -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
8 UIKit 0x0036c123 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
9 UIKit 0x0036d09c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
10 UIKit 0x0036dcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
11 UIKit 0x004a7181 -[UILayoutContainerView layoutSubviews] + 213
12 UIKit 0x0029d267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014d681f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03b4f2ea -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03b430d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03b4f235 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x00358613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x00277177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x00275d16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x00275be8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x00275c70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x00274d0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x00274c6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x002759c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x00278fb6 -[UIWindow setDelegate:] + 449
26 UIKit 0x0034a737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x0026ec1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x0026ed97 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0026f02d -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027989a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x0022ccd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x002313a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0024587c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x00245de9 -[UIApplication sendEvent:] + 85
35 UIKit 0x00233025 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036e82f6 _PurpleEventCallback + 776
37 GraphicsServices 0x036e7e01 PurpleEventCallback + 46
38 CoreFoundation 0x016bcd65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016bca9b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016e777c __CFRunLoopRun + 2156
41 CoreFoundation 0x016e6ac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016e68db CFRunLoopRunInMode + 123
43 UIKit 0x00230add -[UIApplication _run] + 840
44 UIKit 0x00232d3b UIApplicationMain + 1225
45 SliderGalore Puzzle Game 0x000055fd main + 141
46 libdyld.dylib 0x01d7f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
以下是我在某些特定领域的代码:
AppDelegate.h(之前我忽略了rootviewcontroller的代码,一旦我这样做,就会出现错误。如果我不忽略它,我会收到另一个错误,"应用程序窗口是期望在应用程序启动结束时有一个根视图控制器":
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([prefs objectForKey:@"PuzzlePicture"] == nil) {
[prefs setBool:FALSE forKey:@"Refresh"];
[prefs setInteger:0 forKey:@"PuzzlePicture"];
[prefs setBool:TRUE forKey:@"CountMoves"];
//[prefs setBool:TRUE forKey:@"Timer"];
[prefs setInteger:1 forKey:@"PuzzleLayoutX"];
[prefs setInteger:1 forKey:@"PuzzleLayoutY"];
}
/*self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SliderGaloreViewController *sliderGaloreViewController =
(SliderGaloreViewController *)[storyboard
instantiateViewControllerWithIdentifier:@"SliderGaloreViewController"];
self.window.rootViewController = sliderGaloreViewController;
[self.window makeKeyAndVisible];*/
return YES;
ViewController.m:
- (IBAction)showInfo:(id)sender
{
[self performSegueWithIdentifier:@"showInfo" sender:self];
}
/*- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"showInfo"])
{
// Get reference to the destination view controller
SliderGaloreFlipsideViewController *vc = [segue destinationViewController];
NSInteger tagIndex = [(UIButton *)sender tag];
// Pass the information to your destination view
[vc setSelectedButton:tagIndex];
}
}*/
答案 0 :(得分:0)
视图控制器具有view
属性,运行时在加载控制器时尝试连接该属性。错误表明您的控制器没有定义其中一个。
尝试将view
属性与故事板内的UIView
相关联,以使加载逻辑感到满意。