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;

 

posted @ 2022-03-10 20:41  foolish_love  阅读(1139)  评论(0编辑  收藏  举报