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.
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:
- You are using the correct name for the xib and the file exist.
- 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.