ScrollView代理方法的不准确目标contentoffset是iOS bug?

发布于 2025-02-05 20:19:01 字数 790 浏览 0 评论 0原文

我有一个文本视图,其中设置了10000多行的内容,

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textView.delegate = self;
    
    NSMutableString *mustr = [[NSMutableString alloc]init];
    for (int i = 0; i < 100000; i++) {
        [mustr appendFormat:@"%i\n",i];
    }
    self.textView.text = mustr;
}

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    NSLog(@"Get expected stop position:Get expected stop position%f",willEndPoint.y);
}

我设置了一个按钮。停止后,我单击按钮以打印文本视图的真实偏移值,

- (IBAction)TESTBTN:(id)sender {
    NSLog(@"Final roll stop position:%f",self.textView.contentOffset.y);
}

我发现您滑动越多,预期位置和实现位置之间的偏差就越大。有人知道发生了什么吗?是接口错误吗

I have a textview, in which I set more than 10000+ lines of content

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textView.delegate = self;
    
    NSMutableString *mustr = [[NSMutableString alloc]init];
    for (int i = 0; i < 100000; i++) {
        [mustr appendFormat:@"%i\n",i];
    }
    self.textView.text = mustr;
}

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    NSLog(@"Get expected stop position:Get expected stop position%f",willEndPoint.y);
}

I set a button. After stopping, I click the button to print the true offset value of textview

- (IBAction)TESTBTN:(id)sender {
    NSLog(@"Final roll stop position:%f",self.textView.contentOffset.y);
}

I found that the more you slide, the greater the deviation between the expected position and the implementation position. Does anyone know what's going on? Is it an interface bug

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文