Ios 我试着按ViewController,但我做不到

Ios 我试着按ViewController,但我做不到,ios,objective-c,Ios,Objective C,我尝试按Viewcontroller,但它不工作 AppDelegate.m我导入ViewController以将其用作根视图 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ ViewController *view = [[ViewController alloc]init]; self.window.rootViewCo

我尝试按Viewcontroller,但它不工作

AppDelegate.m我导入ViewController以将其用作根视图

- (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.p‌​latform/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'
试试这个: 在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;     
在序列图像板中添加一个新的ViewController,其序列图像板标识符为:RootViewController

- (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;
}

希望有帮助。

在XCode之外重命名某些文件时可能会发生此错误。要解决此问题,您只需从项目中删除文件,右键单击-删除并删除引用,然后重新导入项目中的文件,一切都会正常

另一种选择

在您的错误代码中,无法加载捆绑包中的NIB意味着

名称newView与bundle不匹配

就用这个

ViewController2 *vc2 = [[ViewController2 alloc] init];     
[self.navigationController pushViewController:vc2 animated:YES];
在应用程序delegate.m中添加有效的导航控制器


试试这个

显示错误消息怎么样?我想-在appdelegate中,您没有正确初始化viewcontroller。应该是initWithNibName:@Student我怎么能找到他们的笔尖呢对不起,这个愚蠢的问题,但我beginner@Larmeidk这个应该给你什么?找不到Cbundle 0x8F9BD80未加载的可执行文件2014-07-11 17:10:47.372 pushTest[2007:60b]***由于未捕获异常“NSInternalinconsistenceException”而终止应用程序,原因:“无法在捆绑包中加载NIB:“NSBundle loaded”with name“newViewnib name”应该是firstviewcontroller的xib文件的名称,就像您正在使用newView进行第二次查看一样。感谢您的帮助,但我现在不使用情节提要我正在学习创建没有情节提要的应用程序,非常抱歉,我告诉您了late@BogdanSomlea-提问者使用在“xib不是故事板”中,只需更改xibI对此问题的答案>>self.viewController@propertynonatomic,strongUIViewController*viewController;
ViewController2 *vc2 = [[ViewController2 alloc] init];     
[self.navigationController pushViewController:vc2 animated:YES];