Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 触摸开始于UIScrollView_Iphone_Xcode_Ios4 - Fatal编程技术网

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获取滚动位置,非常感谢。如何识别双击?请查看以下内容: