uitableview - iOS7 UITapGestureRecognizer method is not called -
i working on uipickerview multi selection in ios7 , used uitapgesturerecognizer multi selection.
in ios6 working fine in ios7 toggleselection: (uitapgesturerecognizer) method not called.
so please give me idea or suggestion resolve issue.
please see below code.
- (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { uitableviewcell *cell = (uitableviewcell *)view; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:nil]; [cell setbackgroundcolor:[uicolor clearcolor]]; [cell setbounds: cgrectmake(0, 0, cell.frame.size.width -20 , 44)]; uitapgesturerecognizer *gesturerecog = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(toggleselection:)]; [gesturerecog setdelegate:self]; gesturerecog.numberoftapsrequired = 1; [gesturerecog.view setbackgroundcolor:[uicolor redcolor]]; // [singletapgesturerecognizer.view settag:row]; [cell addgesturerecognizer:gesturerecog]; } if ([self.selecteditems indexofobject:[nsnumber numberwithint:row]] != nsnotfound) { [cell setaccessorytype:uitableviewcellaccessorycheckmark]; } else { [cell setaccessorytype:uitableviewcellaccessorynone]; } cell.tag = row; if (self.flag == 0 ) { if (self.arracountry.count > 0) { cell.textlabel.text=[[self.arracountry objectatindex:row] valueforkey:@"name"]; } } else if (self.flag == 1) { if (self.arrastates.count > 0) { cell.textlabel.text=[[self.arrastates objectatindex:row] valueforkey:@"name"]; } } else if (self.flag == 2) { if (self.arraycity.count > 0) { cell.textlabel.text=[[self.arraycity objectatindex:row] valueforkey:@"name"]; } } return cell; } - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer { return yes; } - (void)toggleselection:(uitapgesturerecognizer *)recognizer { nsnumber *row = [nsnumber numberwithint:recognizer.view.tag]; nsuinteger index = [self.selecteditems indexofobject:row]; if (index != nsnotfound) { [self.selecteditems removeobjectatindex:index]; [(uitableviewcell *)(recognizer.view) setaccessorytype:uitableviewcellaccessorynone]; } else { [self.selecteditems addobject:row]; [(uitableviewcell *)(recognizer.view) setaccessorytype:uitableviewcellaccessorycheckmark]; } }
Comments
Post a Comment