Iphone 触摸开始于UIScrollView
Iphone 触摸开始于UIScrollView,iphone,xcode,ios4,Iphone,Xcode,Ios4,触摸开始:在UIScrollView中不起作用。如何在UIScrollView中启用触摸开始:?您必须将UIScrollView子类化以允许拦截触摸事件 例如,您可以创建一个“特殊”的UISCrollView,如下所示: @interface TouchableScrollView : UIScrollView { } @end .m文件: @implementation TouchableScrollView - (void) touchesEnded: (NSSet *) touche
触摸开始:
在UIScrollView中不起作用。如何在UIScrollView中启用触摸开始:
?您必须将UIScrollView子类化以允许拦截触摸事件
例如,您可以创建一个“特殊”的UISCrollView,如下所示:
@interface TouchableScrollView : UIScrollView {
}
@end
.m文件:
@implementation TouchableScrollView
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
if (!self.dragging) {
[self.nextResponder touchesEnded: touches withEvent:event];
}
[super touchesEnded: touches withEvent: event];
}
@end
此示例仅覆盖touchesEnded,但您可以对ToucheSbegind执行相同的操作。我假设您正在寻找向下滚动并隐藏向下滚动Img的代码。这就是代码
// 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 ;
}
您可以使用myScrollView.contentOffset获取滚动位置,非常感谢。如何识别双击?请查看以下内容: