objective c - How to detect touches on UIImageView of UITableViewCell object in the UITableViewCellStyleSubtitle style -
i using uitableviewcell object in uitableviewcellstylesubtitle style (i.e image view on left, text label in bold , under detail text label) create table. need detect touches on uiimageview , know indexpath/cell in image view clicked. tried using
cell.textlabel.text = @"sometext"; nsstring *path = [[nsbundle mainbundle] pathforresource:@"emptystar1" oftype:@"png"]; uiimage *theimage = [uiimage imagewithcontentsoffile:path]; cell.imageview.image = theimage; cell.imageview.userinteractionenabled = yes; but it's not working. whenever image clicked, didselectrowatindexpath: called. don't want create separate uitableviewcell , add custom button it. there way detect touches on uiimageview itself?
in cellforrowatindexpath method add code
cell.imageview.userinteractionenabled = yes; cell.imageview.tag = indexpath.row; uitapgesturerecognizer *tapped = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(myfunction:)]; tapped.numberoftapsrequired = 1; [cell.imageview addgesturerecognizer:tapped]; [tapped release]; and check imageview clicked, check flag in selector method
-(void)myfunction :(id) sender { uitapgesturerecognizer *gesture = (uitapgesturerecognizer *) sender; nslog(@"tag = %d", gesture.view.tag); }
Comments
Post a Comment