开发者

Why isn't my modal view being displayed in my iOS app?

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)viewDi开发者_如何学运维dAppear:(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!


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜