0

I try to push Viewcontroller it doesn't work.

AppDelegate.m (I import ViewController to use it as rootView)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
ViewController *view = [[ViewController alloc]init];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:view];
return YES;
}

Next is my Viewcontroller.m

-(void)goToView{
ViewController2 *view2 = [[ViewController2 alloc]initWithNibName:@"newView" bundle:nil];
[self.navigationController pushViewController:view2 animated:YES];
}

I got error message:

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'
Larme
  • 24,190
  • 6
  • 51
  • 81
Kana
  • 5
  • 2
  • What about showing the error message? – Larme Jul 11 '14 at 10:04
  • I think - In appdelegate you have not initialized the viewcontroller correctly. it should be initWithNibName: – Yogendra Jul 11 '14 at 10:05
  • @Student how can i find their nib name sorry for stupid question but im beginner – Kana Jul 11 '14 at 10:12
  • @Larme idk what should give you this ? Cannot find executable for CFBundle 0x8f9bd80(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 (loaded)'with name 'newView'' – Kana Jul 11 '14 at 10:18
  • nib name should be the name of your xib file of firstviewcontroller like you are using "newView" for second view. – Yogendra Jul 11 '14 at 10:23

3 Answers3

0

try this: in 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;     

in your Storyboard add a new ViewController with the storyBoard Identifier: "RootViewController".

Bogdan Somlea
  • 604
  • 3
  • 15
  • thank for your help but i do not use storyboard now i learning to create app without storyboard so sorry that im told you late – Kana Jul 11 '14 at 10:20
  • @Bogdan Somlea - the questioner used in the xib not a storyboard, just change your answer for xib – Anbu.Karthik Jul 11 '14 at 10:25
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;
}

Hope it helps.

Iphonenew
  • 299
  • 2
  • 11
0

This error can occure when you rename some files outside XCode. To solve it you can just remove the files from your project (Right Click - Delete and "Remove Reference") You re-import the files in your project and everything will be ok !

another choice

in your error code Could not load NIB in bundle means

ViewController2 *view2 = [[ViewController2 alloc]initWithNibName:@"newView" bundle:nil];

the Name newView does not match with bundle

just use this

ViewController2 *vc2 = [[ViewController2 alloc] init];     
[self.navigationController pushViewController:vc2 animated:YES];

in your app delegate.m add the valid Navigation controller

try this Navigation Controller Push View Controller

Community
  • 1
  • 1
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143