iphone - Display modal view(slideup) in a tab bar interface with navigation bar
I am new to iphone programming and any help would be n开发者_如何学编程ice. I have an application with 3 tabs with the last one going deep, hence created a view based application with tab bar as the root controller and added navigation controller using this link.
In my 2nd tab which is a subclass of UIViewController, I am trying to display a modal view, also being a subclass of UIViewController. In my 2nd tab, when I try to present the modal view, the app crashed and says 'GDB: Program recieved signal:"SIGABRT"'. This is what I have
ModalViewController *mvc = [[ModalViewController alloc] initWithNibName:@"ModalView" bundle:nil];
[self presentModalViewController:mvc animated:YES];
Here 'self' is the 2nd Tab's UIViewController. How to present the modal which is a view controller in the 2nd tab? What am I doing wrong here?
Thanks
ModalViewController *mvc = [[ModalViewController alloc] initWithNibName:@"ModalView" bundle:nil];
[tabBarController presentModalViewController:mvc animated:YES];
[mvc release];
There was memory leak, you must release the object after use [mvc release];
ModalViewController needs to be a child of the TabBarController:
ModalViewController *mvc = [[ModalViewController alloc] initWithNibName:@"ModalView" bundle:nil];
[tabBarController presentModalViewController:newNavController
animated:YES];
精彩评论