Objective C: UIScrollView (pagingEnabled): When Next Page Enters Start The Animation

橙三吉。 提交于 2019-12-12 04:49:49

问题


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.


回答1:


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

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.




回答2:


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



来源:https://stackoverflow.com/questions/9337996/objective-c-uiscrollview-pagingenabled-when-next-page-enters-start-the-anima

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!