我在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,但是我无法实现它,请您用代码清晰地解释给我。非常感谢您提前的帮助。