当前位置: 动力学知识库 > 问答 > 编程问答 >

iphone - What happen on current viewController when i call presentModalViewController

问题描述:

i'm developing an app for iphone, and i use

[self presentModalViewController:aViewControllerInitializateBefore animated:YES];

Can you tell me what happens to the current viewController when i use this?

网友答案:

The current view controller stays "underneath" the modal view controller and will reappear when you call

- (void)dismissModalViewControllerAnimated:(BOOL)animated

either on the modal view or the parent/presenting view controller (as the parent/presenting view controller's view is no longer visible, it's view may be unloaded when the system requires memory, and reloaded on dismiss).

From this method's documentation:

The parent view controller is responsible for dismissing the modal view controller it presented using the presentModalViewController:animated: method. If you call this method on the modal view controller itself, however, the modal view controller automatically forwards the message to its parent view controller.

If you present several modal view controllers in succession, and thus build a stack of modal view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

Also note the change in iOS 5

Prior to iOS 5.0, if a view did not have a parent view controller and was being presented modally, the view controller that was presenting it would be returned. This is no longer the case. You can get the presenting view controller using the presentingViewController property.

分享给朋友:
您可能感兴趣的文章:
随机阅读: