I have an ipad app.
I am trying to open view 2 (kind of push view) full with entire screen. how normally do with push view or UIModalPresentationFullScreen
. but my base view which is view 1 is also modal view.
so i was trying to open view 2 when view 1 get dismiss…
- (void) handleNewButton :(int)id
{
[self dismissViewControllerAnimated:YES
completion:^{
NewViewController *View2 = [NewViewController alloc] init];
View2.modalPresentationStyle = UIModalPresentationFullScreen;
View2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController: View2 animated:YES completion:nil];
}];
}
but my view 2 is not opening. i know i can not do push view. But is there any way to achieve it?.
When you do this dismissViewControllerAnimated
the UIViewController
(self in this case) is gone, in the sense that he is not on the screen anymore, if it has been released or not, that's another story. The reason for you to not be able to show the View2
(very poor name, it should at least ViewController2
) is because you are trying to show it from a UIViewController
that is not on the screen anymore.
So, what can you do?
The current self
in the context of the handleNewButton
method, in theory was presented by another UIViewController
, that's from where you want to present your View2
.
Probably the quickest way of implementing of what I said, would probably be with a notification described here. Although I would do it with a block, so when the self
would be created, I would pass a dismissiCompletionBlock
that would be called when that UIViewController
was dismissed.