I've been reading up a lot about Gesture Recognizers on SO - and have managed to write a working code which when a long-press is recognised on an UIImage, an action sheet appears:
{ ...
UILongPressGestureRecognizer *longPressWall = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(deleteImage:)] autorelease];
longPressWall.minimumPressDuration = 0.4;
l.userInteractionEnabled=YES;
[l addGestureRecognizer:longPressWall];
... }
-(void)deleteImage:(UILongPressGestureRecognizer*)sender {
if(UIGestureRecognizerStateBegan == sender.state) {
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Close" destructiveButtonTitle:@"Delete Screenshot" otherButtonTitles: nil];
[as showInView:masterView];
[as release];
}
}
So, sending information to the Selector deleteImage:
is a little tricky in this situation.
I want to send a HTTP request to a server when deleteImage is called, so I need some information from the view.
Is there anyway to store information into the UIImageView
and retrieve it from sender.view.myinfo
(for example)?
NSMutableArray
to keep track of deleted items, and as you delete, remove the image from the view (or possibly dim it if you don't want to remove it until you get confirmation from the server) and then have your controller add the deleted item in the array that you're using to keep track of this stuff. Or something like that. – Rodenticide