Alex
Alex

Reputation: 11137

removing window from modalviewcontroller

I launch a modal view controller and in its init I have the following code:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
viewController = [[UIViewController alloc]init];
[window addSubview:viewController.view];
[window makeKeyAndVisible];      

I need the viewController for entering some data in it. How can I release the window and viewController so that I can go back to the viewController that launched the modal view controller? At this point, after I'm done doing what I need in the modal view, I am trying:

[viewController.view removeFromSuperview];
[window removeFromSuperview];

but just end up with the modal view's parent (the one that lanched the modal view) just frozen(it's not really frozen, it is just not user interactible because there are the window and view controller in front of it and the view controller doesn't have size and background

Upvotes: 0

Views: 173

Answers (1)

rckoenes
rckoenes

Reputation: 69469

iOS app should only contain one UIWindow. And you can easily present UIViewController with in viewController

[self presentModalViewController:navigationController animated:animated];

Then just call in that viewController to dismiss it:

[self dismissModalViewControllerAnimated:YES];

Upvotes: 1

Related Questions