0

ボタンのクリック時に UIImageview を作成しています。

これは私のコードです:

     _imgfull.userInteractionEnabled=YES;
        _imgfull.clipsToBounds = YES;
        //this all for image positioned
        imgpositioned=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,500,500)];
        imgpositioned.userInteractionEnabled=YES;
        imgpositioned.tag=tag;
        tag++;
        if(tag==1)
        {
            imgpositioned.backgroundColor =[UIColor redColor];
        }
        else
        {
            imgpositioned.backgroundColor =[UIColor greenColor];
        }
//pinch gesture 
        UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(Pinchforimage:)];
        pinch.delegate=self;
        [imgpositioned addGestureRecognizer:pinch];

        // create and configure the rotation gesture
        UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureDetected:)];
        [rotationGestureRecognizer setDelegate:self];
        [imgpositioned addGestureRecognizer:rotationGestureRecognizer];
        // pan gesture
        UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureDetected:)];
        [panGestureRecognizer setDelegate:self];
        [imgpositioned addGestureRecognizer:panGestureRecognizer];
        //long press gesture
        UILongPressGestureRecognizer *longpress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpress:)];
        [longpress setDelegate:self];
        [imgpositioned addGestureRecognizer:longpress];
         [_imgfull addSubview:imgpositioned];

これは私の長押しジェスチャー方法です

[![-(void)longpress:(UILongPressGestureRecognizer *)longg
{

    NSLog(@"gesture recogniser long press obtained ==%d",\[longg.view tag\]);
    UIGestureRecognizerState state =\[longg state\];
    if(state ==UIGestureRecognizerStateBegan ||state ==UIGestureRecognizerStateChanged)
    {
        \[imgpositioned superview\];

    }
}

ここに画像の説明を入力

ユーザーがUIImageviewを長押しすると、UIImageviewを上に移動したい、たとえば、ユーザーが赤いUIImageviewを長押しすると、緑のimageviewの上に来る必要があります:)

友達を助けてください:

4

2 に答える 2

1

メソッドでこのコードを使用[_imgfull bringSubviewToFront:longg.view];します-(void)longpress:(UILongPressGestureRecognizer *)longg

于 2016-03-16T09:41:01.970 に答える