switch between xibs on button action
I'm having 开发者_C百科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"
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.
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];
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...
Don't release he controller its a global variable i suppose so just make it in nil in dealloc
精彩评论