一,TextView用纯代码写。
二,oc的Runtime,创建 文件 UITextViewWorkaround
#import <Foundation/Foundation.h>
-
@interface UITextViewWorkaround : NSObject -
+ (void)executeWorkaround; -
@end
#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;
}
再运行就好了
本文介绍了一种解决iOS 13.2中UITextView布局问题的方法,通过Objective-C Runtime动态注册类来修复布局显示异常,确保应用在不同iOS版本上正常运行。
492

被折叠的 条评论
为什么被折叠?



