美文网首页
批量解决iOS13PresentViewController视图

批量解决iOS13PresentViewController视图

作者: 螺旋爆炸不要怕 | 来源:发表于2019-10-08 08:53 被阅读0次

以下为iOS13新引入的模式,为默认模式

    UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,

以往默认模式为

    UIModalPresentationFullScreen = 0,

如若此模式影响到你的界面可用以下方式解决批量此问题
用runtime修改系统方法 presentViewController:animated:completion:

+(void)load{
    if (@available(iOS 13.0, *)) {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            Class class = [self class];
            SEL originalSelector=@selector(presentViewController:animated:completion:);
            SEL swizzledSelector=@selector(my_presentViewController:animated:completion:);
            Method originalMethod=class_getInstanceMethod(class,originalSelector);
            Method swizzledMethod=class_getInstanceMethod(class,swizzledSelector);
            BOOL didAddMethod = class_addMethod(class,
                            originalSelector,
                            method_getImplementation(swizzledMethod),
                            method_getTypeEncoding(swizzledMethod));
            if(didAddMethod){
                class_replaceMethod(class,
                                    swizzledSelector,
                                    method_getImplementation(originalMethod),
                                    method_getTypeEncoding(originalMethod));
            }else{
                method_exchangeImplementations(originalMethod,swizzledMethod);
            }
        });
    }
}
-(void)my_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion{
    viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
    [self my_presentViewController:viewControllerToPresent animated:YES completion:nil];

}

不用到处去为viewcontroller添加modalPresentationStyle = UIModalPresentationFullScreen,如果你的viewcontroller是继承某个基类,也可直接在父类里init的时候添加modalPresentationStyle = UIModalPresentationFullScreen

相关文章

  • 批量解决iOS13PresentViewController视图

    以下为iOS13新引入的模式,为默认模式 以往默认模式为 如若此模式影响到你的界面可用以下方式解决批量此问题用ru...

  • [MacOS]视图dismissViewController退出

    解决思路: 使用NSNotificationCenter解决. 子视图 子视图中,在执行 [self dismis...

  • Jenkins 批量创建任务的三种方法

    最近,要搭建多套测试环境,需要把 Jenkins 中 dev 视图下的所有任务批量复制到 sit 等视图下。 说明...

  • mysql 批量修改视图定义者 DEFINER

    原文: MySQL如何批量修改视图(VIEW)的属主(DEFINER)参考: Mysql The user spe...

  • PPT模板,让效率翻10倍

    1、建幻灯片-可以选择添加的板式,视图,幻灯片母版 2、批量添加Logo, 批量替换字体:设计-右上角-字体(幻灯...

  • odoo12遇到的错误

    无效视图 odoo.tools.convert.ParseError: "无效视图 原因无法识别视图 解决办法:检...

  • // 解决子视图coloseImg超出父视图不能响应问题

    // 解决子视图coloseImg超出父视图不能响应问题 - (UIView*)hitTest:(CGPoint)...

  • 注解版Mybatis 批量查询,插入(更新暂不支持)

    注解版 Mybatis 3.1.1 不支持