gpt4 book ai didi

ios - UITextView 中带有新行的不正确排除路径

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:15:57 25 4
gpt4 key购买 nike

当 textView 有换行符时,我遇到了 exclusionPaths 的问题:

这是我的代码:

- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 333, 360, 480)];
view.frame = CGRectMake(50, 0, 50, 50);
view.backgroundColor = [UIColor blackColor];
NSLog(@"%@", NSStringFromCGRect(view.frame));
[textView addSubview:view];

CGRect relativeRect = [textView convertRect:view.bounds fromView:view];

UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRect:relativeRect];
textView.text = @"asddsaadasddsasdasdjsdhfjkdhkjdhfgjkldhsgfjlk\n\nhfdsgjklhdfsljkghdklfjgshdgjklfshdfgjklhfglkjdshjklgfdshjklgdfshkljfdsghfjkldghlkjfdghskljgdfhslkjgdfshjklgfdshjkgfdshlkjgdfhskljdgfhsjklgdhsjklfgdshjkglfdshjklgfdshlkjfgdhjklgdfshjdfkslghkjfdlsghjkldsfghjkhdfsgkjlhjgkldfshgdflksjhfdksgjhdfkjlgshfkljdshgjkdfhskjglhdfsjkghdfkjglhdsfkjghkljdfhgkjlhdsfkjlghjkldsfghjklhgsfdjklhgsdfkjlghdsfklgfdhsklg";
textView.textContainer.exclusionPaths = @[bezierPath];
[self.view addSubview:textView];

}

结果如下:

enter image description here

问题是新行字符使排除路径比它们应该的更大。此处也描述了该问题:Newlines in iOS 7 UITextView breaking Text Kit exclusion zone wrapping ,但它显示了如何在使用 Interface Builder 创建 UITextView 时修复此 iOS 7 错误。我将如何以编程方式解决这个问题?谢谢!

最佳答案

所以要禁用的获胜属性是“scrollEnabled”:

textView.editable = NO
textView.scrollEnabled = NO

上面的代码修复了我的 exclusionPaths 问题

关于ios - UITextView 中带有新行的不正确排除路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24681960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com