Objective C: UIScrollView (pagingEnabled): 当下一页进入时开始动画
我很抱歉这个标题我不知道该写什么。
我有一个包含许多页面的滚动视图,每个页面都有不同的动画,当用户切换到该页面时应该启动这些动画。
我尝试了这个:
if (CGPointEqualToPoint (CGPointZero, CGPointZero))
{
//start animation
}
它仅适用于第一页
,当我将其更改为下一页的 CGPointEqualToPoint (CGPointMake (768, 0), CGPointZero) 时,它不起作用。
我正在尝试使用此`,
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
但后来我发现当滚动视图 pagingEnabled
为 YES
时它不起作用。
I'm sorry for the title i don't know what to write there.
I have a scrollView with many pages and in each page there are different animations that should start when the user switch to that page.
i tried this:
if (CGPointEqualToPoint (CGPointZero, CGPointZero))
{
//start animation
}
it worked only for the first page
when i changed it to CGPointEqualToPoint (CGPointMake (768, 0), CGPointZero)
for the next page, it's not working.
i am trying to use this `
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
but then i found out that it is not working when the scrollview pagingEnabled
is YES
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过使用滚动视图的委托方法,您可以获得第一页完成滚动的时间,并通过保留可以启动动画的条件。
by using this delegate method of scroll view you can get when your first page finish scrolling and by keeping conditions you can start animation.
使用滚动视图的
contentOffset
了解您所在的位置。另外,请参阅此问题以了解您需要使用哪些委托方法:如何检测 UIScrollView 何时完成滚动
Use the scroll view's
contentOffset
to learn where you are.Also, see this question to discover what delegate methods you need to be using: How to detect when a UIScrollView has finished scrolling