开发者

iOS How to hide a prior subview

I have a situation where I am performing some initialization in an App. Upon first startup I have to present an EULA with an I Agree/I Don't Agree button selection. When the I Agree selection is made I display a modal view which prompts for a username and password. This all works fine. The problem is that after the username and password are verified and the modal view is dismissed. I am left with the EULA view still being displayed on the screen rather than the base table view of the App. I do the following in the EULA viewcontroller code:

- (IBAction)didAgree:(id)sender {
    LoginViewController *lvc=[[[LoginViewController alloc] init] autorelease];
    lvc.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:lvc animated:YES];
    [self.view removeFromSuperview];
}

If I move the last line (removeFromSuperview) to before the presentModal call then, of course, the Login view does not display.

In the login view controller code I have this after the login button is pressed:

开发者_如何学Go[[self parentViewController] dismissModalViewControllerAnimated:YES];
[[self parentViewController].view removeFromSuperview];

If I run with this code, the modal view disappears and the table view appears briefly before disappearing with the EULA view remaining on the screen. If I comment out the second statement, then I never see the table view.

I know this I am missing something incredibly obvious but I am at a loss and have been stuck on this for quite a while.


I think the problem is here:

[self presentModalViewController:lvc animated:YES];

Mainly the self there. This means that you present the login screen modally from what self is: your EULA-ViewController. You can't remove the EULA screen now.

I suggest presenting the login screen first, maybe either all grayed out or not showing anything at all, and the presenting the EULA modally from it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜