Question

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:

[[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.

Was it helpful?

Solution

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.

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