I have two buttons Add Images and Edit.
from Add Images i m adding multiple images from gallery and can move each imageview on view.
I have made an Draggable class to move each imageview.
@interface Draggable : UIImageView {
AppDelegate *objectDelegate;
CGPoint startLocation;
}
@property (nonatomic,retain) AppDelegate *objectDelegate;
@end
@implementation Draggable
@synthesize objectDelegate;
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
// Retrieve the touch point
objectDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
CGPoint pt = [[touches anyObject] locationInView:self];
startLocation = pt;
[[self superview] bringSubviewToFront:self];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
// Move relative to the original touch point
CGPoint pt = [[touches anyObject] locationInView:self];
CGRect frame = [self frame];
frame.origin.x += pt.x - startLocation.x;
frame.origin.y += pt.y - startLocation.y;
[self setFrame:frame];
}
@end
and that how i added images.
UIImage* image = [[UIImage alloc] init];
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
CGRect cellRectangle;
cellRectangle = CGRectMake(20 ,50,image.size.width/6 ,image.size.height/6 );
//[[self view] addSubview:blockView];
UIImageView *dragger = [[Draggable alloc] initWithFrame:cellRectangle];
[dragger setImage:image];
[dragger setUserInteractionEnabled:YES];
[self.view addSubview:dragger];
now on Edit button i want to edit that particular image to b selected on single touch. like i have 3 images picOne, picTwo and picThree. if i touch picTwo and click Edit i want picTwo to edit (open aviary editor).
What i did to do that i have added this line on Draggable touches begin
UITouch *touch = [touches anyObject];
if ([touch view] == objectDelegate.selectedImageViewFromCanvas)
{
// selestecImageViewFromCanvas is UiImageView.
NSLog(@"dragger");
}
But that statement is always false.
I hope everyone get it what i want. Thanks
Thanks Arpit . i have used gesture recognizer link . i have edit this code. on imagepicker i have set tag on UiView (holderview) and UIImageView (imageview) and when i tap on image then i can get tag value of that holder [sender view].tag . and from that tag i am getting that UIImageView tag like [sender view].tag + 1 ( coz if my holderView tag is 101 than my UIImage tag is 102. )