ios - Select the newly added dynamic row in UITableView -


i working masterdetail view using splitviewcontroller in ipad, master view has tableview add rows dynamically. newly added row sits @ 0 postion. want achieve that, want select newly added row added master table. later when user adds new row, row should selected , added row should deselected.

for have written code below

- (void)selectnewlyaddedrow {             nsindexpath* selectedcellindexpath= [nsindexpath indexpathforrow:0 insection:0];         [m_tableview selectrowatindexpath:selectedcellindexpath animated:true scrollposition:uitableviewscrollpositionnone];         [self tableview:m_tableview didselectrowatindexpath:selectedcellindexpath]; } 

this code works if write in function viewdidappear, if write in cellforrowatindexpath doesnt work..

please provide me correct understanding going wrong.

regards ranjit

viewdidappear wont call when add new row register table reloaded notification , in method notification call select first row hope you....

   - (void)selectfirstrow{          if ([self.tableview numberofsections] > 0 && [self.tableview numberofrowsinsection:0] > 0) {             nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0];             [self.tableview selectrowatindexpath:indexpath animated:yes scrollposition:uitableviewscrollpositiontop];             [self tableview:self.tableview didselectrowatindexpath:indexpath];         }     } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -