在视图控制器调用委托关闭视图后应用程序终止

发布于 2024-09-11 14:09:22 字数 2698 浏览 10 评论 0原文

这里的情况是:我有一个视图控制器,它在函数“viewDidLoad”中调用 AppDelegateIphone 中的函数来终止此视图。 问题是,如果我这样做,就会出现此异常:

splashScreen.view = nil;



    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x029dc919 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x02b2a5de objc_exception_throw + 47
 2   CoreFoundation                      0x02995078 +[NSException raise:format:arguments:] + 136
 3   CoreFoundation                      0x02994fea +[NSException raise:format:] + 58
 4   UIKit                               0x0062a09c -[UIViewController _loadViewFromNibNamed:bundle:] + 295
 5   UIKit                               0x00627cd1 -[UIViewController loadView] + 120
 6   UIKit                               0x00627bab -[UIViewController view] + 56
 7   regioappv2                          0x00003085 -[AppDelegate_iPhone application:didFinishLaunchingWithOptions:] + 97
 8   UIKit                               0x00580543 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
 9   UIKit                               0x005829a1 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 346
 10  UIKit                               0x0058c452 -[UIApplication handleEvent:withNewEvent:] + 1958
 11  UIKit                               0x00585074 -[UIApplication sendEvent:] + 71
 12  UIKit                               0x00589ac4 _UIApplicationHandleEvent + 7495
 13  GraphicsServices                    0x030bfafa PurpleEventCallback + 1578
 14  CoreFoundation                      0x029bddc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
 15  CoreFoundation                      0x0291e737 __CFRunLoopDoSource1 + 215
 16  CoreFoundation                      0x0291b9c3 __CFRunLoopRun + 979
 17  CoreFoundation                      0x0291b280 CFRunLoopRunSpecific + 208
 18  CoreFoundation                      0x0291b1a1 CFRunLoopRunInMode + 97
 19  UIKit                               0x00582226 -[UIApplication _run] + 625
 20  UIKit                               0x0058db58 UIApplicationMain + 1160
 21  regioappv2                          0x000028b4 main + 102
 22  regioappv2                          0x00002845 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

如果我在 appDelegate 本身中使用 splashScreen.view = nil; 调用该函数,那么一切都会正常工作。

请告诉我我的错在哪里,或者我是否应该发布更多代码。

问候

here the situation: i have a viewcontroller which calls in the function "viewDidLoad" a function in the AppDelegateIphone to terminate this view.
The problem is that this exception comes if i make this:

splashScreen.view = nil;



    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x029dc919 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x02b2a5de objc_exception_throw + 47
 2   CoreFoundation                      0x02995078 +[NSException raise:format:arguments:] + 136
 3   CoreFoundation                      0x02994fea +[NSException raise:format:] + 58
 4   UIKit                               0x0062a09c -[UIViewController _loadViewFromNibNamed:bundle:] + 295
 5   UIKit                               0x00627cd1 -[UIViewController loadView] + 120
 6   UIKit                               0x00627bab -[UIViewController view] + 56
 7   regioappv2                          0x00003085 -[AppDelegate_iPhone application:didFinishLaunchingWithOptions:] + 97
 8   UIKit                               0x00580543 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
 9   UIKit                               0x005829a1 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 346
 10  UIKit                               0x0058c452 -[UIApplication handleEvent:withNewEvent:] + 1958
 11  UIKit                               0x00585074 -[UIApplication sendEvent:] + 71
 12  UIKit                               0x00589ac4 _UIApplicationHandleEvent + 7495
 13  GraphicsServices                    0x030bfafa PurpleEventCallback + 1578
 14  CoreFoundation                      0x029bddc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
 15  CoreFoundation                      0x0291e737 __CFRunLoopDoSource1 + 215
 16  CoreFoundation                      0x0291b9c3 __CFRunLoopRun + 979
 17  CoreFoundation                      0x0291b280 CFRunLoopRunSpecific + 208
 18  CoreFoundation                      0x0291b1a1 CFRunLoopRunInMode + 97
 19  UIKit                               0x00582226 -[UIApplication _run] + 625
 20  UIKit                               0x0058db58 UIApplicationMain + 1160
 21  regioappv2                          0x000028b4 main + 102
 22  regioappv2                          0x00002845 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

if I call the function with the splashScreen.view = nil; in the appDelegate itself, then everything is working just fine.

Please tell me where is my fault, or wheather I should post more code.

regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-09-18 14:09:22
loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.

你在界面生成器中制作了视图出口吗?看来你没有设置正确。而且从堆栈跟踪中,很明显 viewDidLoad 尚未被调用,因为视图尚未成功加载。

loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.

Have you made the view outlet in interface builder? Seems that you have not set it up correctly. And also from the stack trace, it's clear that viewDidLoad haven't been called, as the view is yet to be successfully loaded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文