ios - When i use UITapGestureRecognizer for tab UITextfield only in section 0, but section 1 some row cannot tab when select tableviewcell -
my tableview have 2 sections , in section 0 have 1 row make uitextfield
in this, want edit in uitextfield
(section0,row0)
but don't want tab select row (section0,row0)
i use uitapgesturerecognizer
problem can fixed
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { ... if(indexpath.section == 0) { uitapgesturerecognizer *taprecognizer = [[uitapgesturerecognizer alloc]initwithtarget:self action:@selector(didtapanywhere:)]; [cell.contentview addgesturerecognizer:taprecognizer]; } ... }
but when scroll table , click in section 1 in row 3,row6,row9,… cannot tab call didselectrowatindexpath
function.
when comment out //uitapgesturerecognizer
section 1 in row 3,row6,row9,… can select section 0 row 0 can select (i don’t want).
i think problem draw cellforrowatindexpath
when scroll, don’t know way solve problem.
thank you
picture sample problem:
if want edit don't want tab select row (section0,row0) don't need add taprecognizer it. better
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if (indexpath.section == 0 && indexpath.row == 0) { [self.view endediting:yes]; return; } // other section , row code }
if want not change cell color when tap @ cell
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { // code init cell here if (indexpath.section == 0 && indexpath.row == 0) { cell.selectionstyle = uitableviewcellselectionstylenone; } else { cell.selectionstyle = uitableviewcellselectionstyledefault; } }
Comments
Post a Comment