我尝试推送Viewcontroller它不起作用。
AppDelegate.m(我导入ViewController以将其用作rootView)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
ViewController *view = [[ViewController alloc]init];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:view];
return YES;
}
接下来是我的Viewcontroller.m
-(void)goToView{
ViewController2 *view2 = [[ViewController2 alloc]initWithNibName:@"newView" bundle:nil];
[self.navigationController pushViewController:view2 animated:YES];
}
我收到错误消息:
Cannot find executable for CFBundle 0x8f9bd80</Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle>(not loaded)
2014-07-11 17:10:47.372 pushTest[2007:60b]***Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/home/Library/Application Support/iPhone Simulator/7.1/Applications/0D78CE53-F02B-467F-8250-8D2D3639A301/sta.app> (loaded)'with name 'newView'
答案 0 :(得分:0)
试试这个: 在AppDelegate中
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
RootViewController *rvc = [mainStoryboard instantiateViewControllerWithIdentifier:@"RootViewController"];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:rvc];
self.window.rootViewController = nc;
在你的Storyboard中添加一个带有storyBoard标识符的新ViewController:&#34; RootViewController&#34;。
答案 1 :(得分:0)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navc;
[_window addSubview:navc.view];
[self.window makeKeyAndVisible];
return YES;
}
希望它有所帮助。
答案 2 :(得分:0)
当您在XCode外部重命名某些文件时,可能会发生此错误。要解决它,您只需从项目中删除文件(右键单击 - 删除和“删除参考”)您重新导入项目中的文件,一切都会好的!
另一种选择
错误代码中的 Could not load NIB in bundle
表示
ViewController2 *view2 = [[ViewController2 alloc]initWithNibName:@"newView" bundle:nil];
名称newView
与捆绑包
只需使用此
ViewController2 *vc2 = [[ViewController2 alloc] init];
[self.navigationController pushViewController:vc2 animated:YES];
在app app delegate.m中添加有效的导航控制器