3

I did this touch actions in UIView, ie, in a uiview there are two or three subviews v1,v2,v3. I used the code below to place the image i1,i2,i3 in corresponding views and if I moves the touch the images move to that point in the view.

- (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;
    }
}

Now I have to do this for a sequence of 28 images so I went for Uiscrollview but I cant get that please explain me clearly with code. thanks a lot in advance for your help.

Jhaliya - Praveen Sharma
  • 31,542
  • 8
  • 70
  • 75
Nazik
  • 8,607
  • 26
  • 75
  • 122

1 Answers1

2

You need to subclass UIScrollView to get touch events of UIScrollView.

Rahul Vyas
  • 27,474
  • 48
  • 179
  • 252