iOS scrollView setContentOffset 同步问题 [英] iOS scrollView setContentOffset synchronization issue
本文介绍了iOS scrollView setContentOffset 同步问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用一个子视图初始化了一个 UIScrollView.按钮操作后,我想:
I initialize a UIScrollView with a subview. After a button action I want to:
- 添加新的子视图
- 滚动到带有动画的新子视图
- 在动画完成后删除旧的子视图.
为此,我执行以下操作:
for that i do the following:
[mCubeView setContentOffset:tOffset animated:YES];
[tActualSide removeFromSuperview];
问题在于,在动画开始后,tActualSide"会立即被移除,并且也会从动画中移除.
The problem is that right after the animation begins the "tActualSide" gets removed instantly and it will be removed from the animation as well.
我想同步它,tActualSide 只会在动画结束时被移除.
I would like to synchronize it that the tActualSide is only going to be removed when the animation ends.
我该怎么做?
推荐答案
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
[mCubeView setContentOffset:tOffset];
[UIView commitAnimations];
[self performSelector:@selector(remove) withObject:nil afterDelay:0.5f];
- (void)remove
{
[tActualSide removeFromSuperview];
}
这篇关于iOS scrollView setContentOffset 同步问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文