UIScrollview涉及开始,触摸移动,触摸行动 [英] UIScrollview touchesbegan,touchesmoved,touchesended actions

查看:140
本文介绍了UIScrollview涉及开始,触摸移动,触摸行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

现在我必须为28的序列执行此操作图像,所以我去Uiscrollview,但我不能得到,请用代码清楚地解释我。非常感谢您的帮助。

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.

推荐答案

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

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

这篇关于UIScrollview涉及开始,触摸移动,触摸行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆