未捕获的异常 'NSInternalInconsistencyException'
生活随笔
收集整理的這篇文章主要介紹了
未捕获的异常 'NSInternalInconsistencyException'
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
實(shí)現(xiàn)功能
通過(guò)下面的代碼,需要在iOS設(shè)備屏幕的一角中顯示文本“hellow xcode”:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Override point for customization after application launch.NSLog(@"程序正在進(jìn)入前臺(tái)");self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];UILabel *myMessage;myMessage = [[UILabel alloc] initWithFrame:CGRectMake(30.0, 50.0, 300.0, 500.0)];myMessage.font = [UIFont systemFontOfSize:48];myMessage.text = @"hellow xcode";myMessage.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];[self.window addSubview:myMessage];self.window.backgroundColor = [UIColor whiteColor];[self.window makeKeyAndVisible];return YES; }出現(xiàn)錯(cuò)誤
2015-12-05 15:07:10.210 iOSCase[1410:579208] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.29.5/UIApplication.m:3299 2015-12-05 15:07:10.215 iOSCase[1410:579208] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch' *** First throw call stack: (0x183c50f48 0x198803f80 0x183c50e18 0x184b44a1c 0x18948c414 0x189488f50 0x18da6f7c4 0x18da6fb44 0x183c08544 0x183c07fd8 0x183c05cd8 0x183b34ca0 0x1892521c8 0x18924cffc 0x100070814 0x1990528b8) libc++abi.dylib: terminating with uncaught exception of type NSException錯(cuò)誤原因
把didFinishLaunchingWithOptions中的代碼全部放在.m和.h文件中,只留下return YES;
總結(jié)
以上是生活随笔為你收集整理的未捕获的异常 'NSInternalInconsistencyException'的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 在虚拟机中安装Windows XP
- 下一篇: Oracle 跨库 查询 复制表数据 分