开发者

UIScrollview touchesbegan,touchesmoved,touchesended actions

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开发者_Go百科 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜