iOS開發之--全局解決模態彈出不全屏展示問題


利用tuntime的特性,創建一個UIViewController的類別,然后再pch文件里面調用即可,代碼如下:

.h

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIViewController (SKPVCModel)

@end

NS_ASSUME_NONNULL_END

.m

#import "UIViewController+SKPVCModel.h"
#import <objc/runtime.h>

@implementation UIViewController (SKPVCModel)

+(void)load{
       Method m1 = class_getInstanceMethod([self class], @selector(presentViewController:animated:completion:));
       Method m2 = class_getInstanceMethod([self class], @selector(skp_presentViewController:animated:completion:));
       method_exchangeImplementations(m1, m2);
}

- (void)skp_presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion{
    viewControllerToPresent.modalPresentationStyle =  UIModalPresentationFullScreen;
    [self skp_presentViewController:viewControllerToPresent animated:flag completion:completion];
}

@end

這樣的話,就可以了!

僅做記錄!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM