I have to customize the transition between 2 different UIViewController and for that I would like to re-implement [UIViewController presentModalViewController...]. What is inside this function? Ho开发者_高级运维w does it work? What does it do?
Thanks a lot, Vance
The -[UIViewController presentModalViewController:animated:]
do allot of magic behind the scenes.
For my app Tweet Note I wanted to present modal view controllers by animating the new view from the backside of a view in a shelf. More or less what iBooks does. I tried to override the default implementation but ended up doing it in a multi step solution that works without ugly hacks and caveats:
- Instantiate the new view controller.
- Apply the transform to the new view controller's managed view, so that it starts in it's initial location.¨
- Start animating the view into untransformed "normal" position.
- Wait for animation to finish, and do as a unit:
- Remove the view you just animated from screen.
- Call
[self presentModalViewController:vc animated:NO]
.
That last step is important! After your transition animation completes present the modal view controller as normal but without animation, and will appear to the user just as if you did a proper animated presentation.
Dismissing with your custom transition is more or less doing the same thing but in reverse order.
精彩评论