UIScrollView - detect image is in the middle of the screen
I am cre开发者_如何学运维ating an iPhone application and I have a UIScrollView. I'd like to ask how to detect that the imageview is in the middle of the page to display its label below the UIscrollview.
Thanks!
hmm, you'd have to make your class conform to the UIScrollViewDelegate
then use:
– scrollViewWillBeginDragging:
to set an NSTimer to run a method which will check if myImage.center == myScrollView.center
and then use – scrollViewDidEndDecelerating:
to stop the timer.
When you are scrolling your scroll view, a method of UIScrollViewDelegate will be called repeatedly during scrolling.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
You can get the current context offset by scrollView's property.
- scrollViewWillBeginDragging and -scrollViewDidEndDecelerating won't be called, if you scroll the view by commands, which are in the UIScrollView class.
精彩评论