* dismissModalViewControllerAnimated *
dismiss 顺序问题:
A present B , B present C.
B 作为主体调用dismiss方法时,首先找自己作为presenter present出来的视图,将其dismiss掉。
/*
The next two methods are replacements for presentModalViewController:animated and dismissModalViewControllerAnimated: The completion handler, if provided, will be invoked after the presented controllers viewDidAppear: callback is invoked.
*/
@available(iOS 5.0, *)
public func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?)
// The completion handler, if provided, will be invoked after the dismissed controller's viewDidDisappear: callback is invoked.
@available(iOS 5.0, *)
public func dismissViewControllerAnimated(flag: Bool, completion: (() -> Void)?)
* addChildViewController *
If the view belonging to a view controller is added to a view hierarchy directly, the view controller will not receive this message. If you insert or add a view to the view hierarchy, and it has a view controller, you should send the associated view controller this message directly. Failing to send the view controller this message will prevent any associated animation from being displayed
本文解析了iOS中UIViewController的dismiss顺序及addChildViewController的使用细节。当从A控制器展示B控制器,再从B控制器展示C控制器时,B控制器调用dismiss方法会先移除最近展示的C控制器。文章还讨论了直接将视图控制器的视图添加到视图层级时需要注意的事项。
4313

被折叠的 条评论
为什么被折叠?



