gpt4 book ai didi

iOS scrollView setContentOffset 同步问题

转载 作者:行者123 更新时间:2023-12-01 17:27:04 27 4
gpt4 key购买 nike

我用 subview 初始化 UIScrollView。按钮操作后,我想:

  • 添加新的 subview
  • 滚动到带有动画的新 subview
  • 动画完成后删除旧的 subview 。

  • 为此,我执行以下操作:
    [mCubeView setContentOffset:tOffset animated:YES];    
    [tActualSide removeFromSuperview];

    问题是,在动画开始后,“tActualSide”会立即被删除,它也会从动画中删除。

    我想同步它, tActualSide 只会在动画结束时被删除。

    我怎样才能做到这一点?

    最佳答案

    监听委托(delegate)回调:

    - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

    当您收到该消息时
    [tActualSide removeFromSuperview];

    引用 Apple 文档(注意“setContentOffset:animated:”引用):
    scrollViewDidEndScrollingAnimation:
    Tells the delegate when a scrolling animation in the scroll view concludes.

    - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
    Parameters
    scrollView
    The scroll-view object that is performing the scrolling animation.
    Discussion
    The scroll view calls this method at the end of its implementations of the UIScrollView and setContentOffset:animated: and scrollRectToVisible:animated: methods, but only if animations are requested.

    Availability
    Available in iOS 2.0 and later.
    Declared In
    UIScrollView.h

    关于iOS scrollView setContentOffset 同步问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11723594/

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