美文网首页
iOS:解决Xcode11.2在xib里加载UITextView

iOS:解决Xcode11.2在xib里加载UITextView

作者: 春暖花已开 | 来源:发表于2019-06-26 22:26 被阅读0次

崩溃日志:'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

      本文链接:https://www.haomeiwen.com/subject/bcqkcctx.html