开发者

How do I replace a modal view controller?

I'm using a modal view controller to allow a user to select an address book entry and email address. The ABPeoplePickerNavigationController object is displayed via presentModalViewController:animated:

[self presentModalViewController:picker animated:YES];

What I want to do is keep the modal dialog up, but when the user selects the email address, it should cross-fade to a different controller that displays a message composition window.

I've tried various approaches in peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier: to dismiss the picker and set my custom composition controller as the modal view. I can do it any number of ways, but never does it fade smoothly from the picker to the composition contr开发者_JS百科oller -- unless I make the composition controller a modal dialog of the picker, in which case the picker re-appears when I dismiss the composition controller. I don't want that, either.

There must be some way to smoothly replace one controller and its view with another controller and its view, all within the context of a modal dialog, and preferably with a cross fade. Suggestions greatly appreciated.


Add the composition controller as a subview of your picker. Set its alpha to 0 so it is transparent. Then use an animation block to gradually animate its alpha to full:

// Initially set alpha to 0    
[myCompositionView setAlpha:0];

// Later when you want to show the view, animate the alpha to 1.0
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[myCompositionView setAlpha:1.0];
[UIView commitAnimations];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜