Xcode 11.x Xib _UITextLayoutView 崩溃问题

崩溃信息如下:

'Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found;

解决方案:

解决方案 一

1.xib的部分视图改用硬核手写,以避坑。

解决方案 二

2.[下载其他版本Xcode 传送门]

解决方案 三

3.OC 黑魔法 Runtime

创建 文件 UITextViewWorkaround

UITextViewWorkaround.h
#import <Foundation/Foundation.h>
 
@interface UITextViewWorkaround : NSObject
+ (void)executeWorkaround; 
@end
 
UITextViewWorkaround.m
#import "UITextViewWorkaround.h"
#import  <objc/runtime.h>
 
 
 
@implementation UITextViewWorkaround
 
+ (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
        }
    }
}
 
@end

-使用该静态方法

#import "UITextViewWorkaround.h"
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
 
    [UITextViewWorkaround executeWorkaround];
    return yes;
}

swift 版本如收下:

import UIKit
 
@objc
class UITextViewWorkaround : NSObject {
 
    static func executeWorkaround() {
        if #available(iOS 13.2, *) {
        } else {
            let className = "_UITextLayoutView"
            let theClass = objc_getClass(className)
            if theClass == nil {
                let classPair: AnyClass? = objc_allocateClassPair(UIView.self, className, 0)
                objc_registerClassPair(classPair!)
            }
        }
    }
 }
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,792评论 1 32
  • 张东辉,焦点初级第43期坚持原创分享第551天(2019.3.7) 今天上午,下到园所,听两节中大班品格绘本阅读课...
    星悦传奇阅读 847评论 0 1
  • 前端更新实在快,自己感觉呗甩老远,经理告诉我有一个需求,是屏幕截屏,蒙了,js还能实现这功能?然后抱着试试的心态,...
    月光_薛阅读 4,007评论 0 1
  • 我的记性一直很好,不是对于英语单词记忆快或好,或是有着过目不忘的能力,我一直记得我做过和经历过的一些事情,但是...
    卡绫阅读 365评论 0 0

友情链接更多精彩内容