Question

This is my code to navigate to another nib,

  MaintenanceViewController *maintenance = [[MaintenanceViewController alloc] initWithNibName:@"MaintenanceViewController" bundle:nil];
  CGRect theFrame = maintenance.view.frame;
  theFrame.origin = CGPointMake(self.view.frame.size.width, 0);
  maintenance.view.frame = theFrame;
  theFrame.origin = CGPointMake(0,0);
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.6f];
  maintenance.view.frame = theFrame;
  [UIView commitAnimations];
  [self.view addSubview:maintenance.view];

note that I am not using navigation controller and also I dont want to as my app is not based on navigation.

When This method is called on second line i.e. getting frame(theframe) the app got crashed with error Exec_bad_access code=2 address = 0xbf7ffffc.

So nib couldn't loaded.

Was it helpful?

Solution 2

First thing first; your app is crashing because you are having a call on a nill variable: maintenance. You need to ensure that the loading of your nib file is happening correctly.

There are different reasons this is not happening; check:

  1. You are using the correct name for the xib and the file exist.
  2. You have defined correctly the xib file's "File owner": your view controller.

Second thing; i think what you want is to present modally your second view controller which can be accomplished by making a call to the presenting view controller with the presentViewController:animated:completion: method.

OTHER TIPS

Check this Sample SlideMenu

It may help to solve your issue

To navigate to another viewController you should use the presentViewController method like this:

MaintenanceViewController *maintenance = [[MaintenanceViewController alloc] initWithNibName:@"MaintenanceViewController" bundle:nil];
[maintenance setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:maintenance
                   animated:YES
                 completion:^(void){
                 }
 ];

Also, depending on how you setup your MaintenanceViewController you may not need to use initWithNibName

MaintenanceViewController *maintenance = [[MaintenanceViewController alloc] init];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top