SettingsViewController *viewController = [[SettingsViewController alloc] init];
[[self navigationController] pushViewController:viewController animated:YES];
Run Code Online (Sandbox Code Playgroud)
在NavigationController中使用此代码时,显示的场景只是一个黑屏.在故事板中,它显示内容但不会显示在手机上.
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"SettingsViewController"];
[[self navigationController] pushViewController:vc animated:YES];
Run Code Online (Sandbox Code Playgroud)
试图从Storyboard中的NavigationController推送视图控制器,我不断收到此错误.
*由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[<SettingsViewController 0x1f98f100> setValue:forUndefinedKey:]:此类不是键值keyPath的密钥值编码兼容.*第一掷调用堆栈:(0x31f4a3e7 0x39c3b963 0x31f4a0d5 0x327b87d9 0x327b4543 0x31ed08a5 0x33ef5e69 0x340e5b09 0x71aa3 0x33e1b31d 0x33e9dda9 0x32859657 0x31f1f857 0x31f1f503 0x31f1e177 0x31e9123d 0x31e910c9 0x35a6f33b 0x33dad2b9 0x6567d 0x3a068b20)的libc ++ abi.dylib:终止叫做抛出一个异常