Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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_Objective C_Uiscrollview - Fatal编程技术网

Iphone UIScrollview触摸开始、触摸移动、触摸取消操作

Iphone UIScrollview触摸开始、触摸移动、触摸取消操作,iphone,objective-c,uiscrollview,Iphone,Objective C,Uiscrollview,我在UIView中做了这个触摸动作, 在uiview中有两个或三个子视图v1、v2、v3。我使用下面的代码将图像i1、i2、i3放置在相应的视图中,如果我移动触摸,图像将移动到视图中的该点 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch view] == v1) { CGPo

我在UIView中做了这个触摸动作, 在uiview中有两个或三个子视图v1、v2、v3。我使用下面的代码将图像i1、i2、i3放置在相应的视图中,如果我移动触摸,图像将移动到视图中的该点

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    if ([touch view] == v1)
    {
        CGPoint location = [touch locationInView:v1];
        i1.center = location;
    }
        else if([touch view] == v2)
    {
        CGPoint location = [touch locationInView:v2];
        i2.center = location;
    }
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    if ([touch view] == v1)
    {
        CGPoint location = [touch locationInView:v1];
        i1.center = location;
    }
        else if([touch view] == v2)
    {
        CGPoint location = [touch locationInView:v1];
        i2.center = location;
    }
}

现在我必须对28幅图像的序列执行此操作,所以我选择了Uiscrollview,但我无法获得,请用代码清楚地解释我。非常感谢您的帮助。

您需要对UIScrollView进行子类化以获取UIScrollView的触摸事件。

如何对UIScrollView进行子类化请通过此链接进行解释