touch began in UIScrollView
touchesBegan:
d开发者_StackOverflow中文版oesn't work in UIScrollView. How do I enable touchesBegan:
in UIScrollView?
You have to subclass UIScrollView to allow interception of the touch events.
For example, you could create a "special" UISCrollView like this:
@interface TouchableScrollView : UIScrollView {
}
@end
.m file:
@implementation TouchableScrollView
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
if (!self.dragging) {
[self.nextResponder touchesEnded: touches withEvent:event];
}
[super touchesEnded: touches withEvent: event];
}
@end
This example only overrides touchesEnded, but you can do the same for touchesBegan
I assume that u are seeking for code to scroll down and hide the scroll down Img. so this is the code.
// scroll down image show and hidder.
- (void)scrollViewDidScroll:(UIScrollView *)myScrollView{
//NSLog(@"%lf",myScrollView.contentOffset.y);
if (myScrollView.contentOffset.y > 220 )
scrollDownImg.hidden = YES ;
else
scrollDownImg.hidden = NO ;
}
U may get the scrolled location by using the myScrollView.contentOffset
精彩评论