UIScrollview 无法保持水平

发布于 2024-10-04 07:24:03 字数 273 浏览 5 评论 0原文

我有 2 个彼此相邻的 UIScrollview。 它们因其垂直价值而联系在一起。 (向上和向下)

事实证明,当我在两个视图上绘制某种图形时(实际上在每个视图中......但图形(一条线)在视觉上是交叉的)。在某个时刻,当你 疯狂地平移并开始加速和减速,滚动视图不会保持水平。 当停止此操作时,它们会再次升级(以某种动画方式),但我实际上希望它们无论用户做什么都粘在一起。

我玩了很多,但我已经没有想法了,所以任何帮助将不胜感激。

谢谢

汤姆

I have 2 UIScrollviews next to each other.
They are hooked up together on their vertical-value. (up and down)

As it turned out as I drew some sort of graphic across both views (actually in each of the views... but the graphic (a line) goes visually across). At some point when you
pan wildly around and start accelerating and decelerating it, the scrollviews don't keep level.
When stopping this, they level up again (in some sort of animation), but I actually want them to stick together no matter what the user does.

I played around a lot, but I am running out of ideas, so any help would be greatly appreciated.

Thank you

Tom

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

腻橙味 2024-10-11 07:24:03

所以如果你缓慢平移它会起作用吗?
我认为这取决于你如何将 uiscrollviews 连接在一起......我的意思是你将垂直值从一个传递到另一个,但不是加速度,不是吗?请发布一些代码

so it works if you're panning slowly?
i think it depends on how you hook uiscrollviews together... i mean you're passing vertical values from one to the other one but not the acceleration isn't it? post some code please

一片旧的回忆 2024-10-11 07:24:03

是的,它运作缓慢。如果我平移速度非常快,它甚至会很有效,但如果我做了很多停止和加速之类的事情,它就会崩溃。

基本上我在我的视图控制器中创建了我的 uiscrollview 并将它们连接到 IB 中。
我正在使用 scrollviewdidScroll-delegate-method 来保持它们同步。我也用 KVO 尝试过,但没有区别。有趣的是,我在内容滚动视图之上也有一个滚动视图。无论我在做什么,我都从未设法使它们(内容滚动和列滚动)不同步。

  • (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
    if (scrollView.dragging ||scrollView.tracking)
    {

    if(rowScrollView==scrollView) 
    {
        [contentScrollView setContentOffset:CGPointMake(contentScrollView.contentOffset.x,scrollView.contentOffset.y)动画:NO];
    } 
    否则如果(columnScrollView==scrollView) 
    {
        [contentScrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, contentScrollView.contentOffset.y) 动画:NO];
    }
    否则如果(contentScrollView==scrollView)
    {
        [columnScrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0) 动画:NO];
        [rowScrollView setContentOffset:CGPointMake(0,scrollView.contentOffset.y)动画:否];
    }
    

    }

谢谢

汤姆

yeah, it works slowly. it works even sweet if I pan very quickly, but it breaks if i do a lot of stopping and accelerating and stuff.

basically I created my uiscrollview in my viewcontroller and hooked them up in IB.
i am using the scrollviewdidScroll-delegate-method to keep them synchronised. i tried it with KVO as well, but no difference. the funny thing is, I have a scrollview on top of the content-scrollview too. I have never managed to get them(contentscroll and columnscroll) out of sync, no matter what I am doing.

  • (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
    if (scrollView.dragging || scrollView.tracking)
    {

    if (rowScrollView == scrollView) 
    {
        [contentScrollView setContentOffset:CGPointMake(contentScrollView.contentOffset.x, scrollView.contentOffset.y) animated:NO];
    } 
    else if (columnScrollView == scrollView) 
    {
        [contentScrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, contentScrollView.contentOffset.y) animated:NO];
    }
    else if (contentScrollView == scrollView)
    {
        [columnScrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0) animated:NO];
        [rowScrollView setContentOffset:CGPointMake(0, scrollView.contentOffset.y) animated:NO];
    }
    

    }

thank you

Tom

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文