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

創(chuàng)建 文件 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

-使用該靜態(tài)方法

#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!)
            }
        }
    }
 }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

  • Swift1> Swift和OC的區(qū)別1.1> Swift沒有地址/指針的概念1.2> 泛型1.3> 類型嚴謹 對...
    cosWriter閱讀 11,684評論 1 32
  • 張東輝,焦點初級第43期堅持原創(chuàng)分享第551天(2019.3.7) 今天上午,下到園所,聽兩節(jié)中大班品格繪本閱讀課...
    星悅傳奇閱讀 830評論 0 1
  • 前端更新實在快,自己感覺唄甩老遠,經(jīng)理告訴我有一個需求,是屏幕截屏,蒙了,js還能實現(xiàn)這功能?然后抱著試試的心態(tài),...
    月光_薛閱讀 3,990評論 0 1
  • 我的記性一直很好,不是對于英語單詞記憶快或好,或是有著過目不忘的能力,我一直記得我做過和經(jīng)歷過的一些事情,但是...
    卡綾閱讀 364評論 0 0

友情鏈接更多精彩內(nèi)容