0
votes

I am new to iphone programming and any help would be nice. 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

2

2 Answers

0
votes
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];

0
votes

ModalViewController needs to be a child of the TabBarController:

ModalViewController *mvc = [[ModalViewController alloc] initWithNibName:@"ModalView" bundle:nil];
[tabBarController presentModalViewController:newNavController
                                                       animated:YES];