Iphone UIScrollview触摸开始、触摸移动、触摸取消操作
我在UIView中做了这个触摸动作, 在uiview中有两个或三个子视图v1、v2、v3。我使用下面的代码将图像i1、i2、i3放置在相应的视图中,如果我移动触摸,图像将移动到视图中的该点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
- (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进行子类化请通过此链接进行解释