Question

I have a tabbar-based iOS app with two tabs. When I tab into the second view, I want it to immediately present a modal view to the user. Here's my simple code for this...

- (void)viewDidAppear:(BOOL)animated
{
 [super viewDidAppear:animated];

 MyViewController_iPhone *myVC = [[MyViewController_iPhone alloc] initWithNibName:@"MyView" bundle:nil];
 [[self navigationController] presentModalViewController:myVC animated:YES];
 [myVC release];
}

When I run my app and tab into the second view, the modal view doesn't show. When I step through it in the debugger, the debugger shows all these lines of code being successfully executed, but I still don't see anything on the screen. In IB, all my classes and connections are correctly set for the "MyView" nib. Any suggestions?

Also, I'm new to iOS development so I'm not sure if this is normal or not, but when I step through this in the debugger, I notice that I'm stepping through the viewDidAppear method for the view in the second tab, yet when I look at my iOS device the app is still displaying the view for the first tab. If I'm stepping through the viewDidAppear method for a specific view, shouldn't that view be displayed on the device at that point?

Thanks so much in advance for your help!

Was it helpful?

Solution

You say your view is in a tabbar based app, but you don't mention if the tabs have UINavigationControllers in them. I mention this because you're calling presentModalViewController:animated: on the result of [self navigationController], which if you see nothing happening, I suspect is nil. Perhaps you wanted to be calling it on [self tabBarController] instead?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top