I am creating UIImageview on button click .
This is my code :
_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];
This is my long press gesture method
[![-(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\];
}
}
When user long press the UIImageview i want to move the UIImageview to above ,for eg if user long press the red UIImageview it have to come above the green imageview :)
possible help me friends :
-(void)longpress:(UILongPressGestureRecognizer *)longg
{
UIGestureRecognizerState state =[longg state];
if(state ==UIGestureRecognizerStateBegan ||state ==UIGestureRecognizerStateChanged)
{
int temptag=[longg.view tag];
UIImageView *views=(UIImageView *)arrimgstore[temptag];
NSLog(@"got it to super view %@",views);
[_imgfull bringSubviewToFront:views];
}
}
finally i done my job ,
Notes :
I am stored my UIImageview inside NSMutable array ,then using gesture view tag ,get those particular UIImageview to front position :).