两个小Points

本文解析了iOS中UIViewController的dismiss顺序及addChildViewController的使用细节。当从A控制器展示B控制器,再从B控制器展示C控制器时,B控制器调用dismiss方法会先移除最近展示的C控制器。文章还讨论了直接将视图控制器的视图添加到视图层级时需要注意的事项。

* 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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值