iOS13 presentViewController的modalPresentationStyle问题
presentViewController的modalPresentationStyle问题:
首先我们查看一下UIModalPresentationStyle,对比以前的看看有什么变化没有。发现新增了一个枚举值UIModalPresentationAutomatic,默认的就是这个,所以才会弹出不是全屏的界面。
typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),
UIModalPresentationCustom API_AVAILABLE(ios(7.0)),
UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),
UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),
UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),
UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),
UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,
UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,
};
注意:presentViewController默认的UIModalPresentationAutomatic推出新的VC的时候,原VC不会调用viewWillDisappear与viewDidDisappear方法;退出新VC时,原VC不会调用viewWillAppear与viewDidAppear方法。
eg:vcA presentViewController vcB
vcA->vcB:vcA不会调用viewWillDisappear与viewDidDisappear方法;
vcB->vcA:vcA不会调用viewWillAppear与viewDidAppear方法;
如果需要vcA 调用 调用viewWillDisappear与viewDidDisappear 修改modalPresentationStylew为UIModalPresentationFullScreen;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix