iOS:解决Xcode11.2在xib里加载UITextView导致崩溃

崩溃日志:'Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found;

解决方案:方案来自Stack Overflow

新建一个类MZUITextViewWorkaround

+ (void)executeWorkaround {
    if (@available(iOS 13.2, *)) {
    }
    else {
        const char *className = "_UITextLayoutView";
        Class cls = objc_getClass(className);
        if (cls == nil) {
            cls = objc_allocateClassPair([UIView class], className, 0);
            objc_registerClassPair(cls);
#if DEBUG
            printf("added %s dynamically\n", className);
#endif
        }
    }
}

AppDelegate里调用:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [MZUITextViewWorkaround executeWorkaround];
    return YES;
}

你可能感兴趣的:(iOS:解决Xcode11.2在xib里加载UITextView导致崩溃)