Reputation: 1977
I'm having difficulty in switching between xibs :(
first i was using navigationController and it worked well but i want to do it without using navigationController.
I tried presentModalViewController but it crashes my application. :((
Here is the code :
myViewController *viewController = [myViewController alloc] initWithNibName:nil bundle:nil];
myViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: myViewController animated:YES];
[myViewController release];
It is not working, ERROR received : GDB:Program received signal : "EXC_BAD_ACCESS"
Upvotes: 1
Views: 413
Reputation: 1501
Don't release he controller its a global variable i suppose so just make it in nil in dealloc
Upvotes: 0
Reputation: 26
myViewController *viewController = [myViewController alloc] initWithNibName:nil bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: viewController animated:YES];
this should work. your problem was that you declared a view controller and named it "viewController", but you were not using that. you were using the view controllers name, not the declared instance.
Upvotes: 1
Reputation: 5098
remove the release statement from ur code and everything will work fine.
Actually u r releasing the viewcontroller before it is shown as the superview.
//[myViewController release];
Hope this helps u...
Upvotes: 0
Reputation: 1457
You have set your nibName to nil
Enter the name of your Xib file you want to display there
Like
myViewController *viewController = [[myViewController alloc] initWithNibName:@"nameOfYourXIB" bundle:nil]autorelease];
myViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: myViewController animated:YES];
Upvotes: 0