iphone - when select row the first selectedrow shows blank -
in viewdidload, called tableview selectrowatindexpath @ row 0, after when click other rows, row 0 shows blank. what's wrong? code:
- (void)viewdidload { uitableview *lefttableview = [[uitableview alloc] initwithframe:cgrectmake(0, 0, 130, 300)]; lefttableview.datasource = self; lefttableview.delegate = self; lefttableview.tag = 0; [lefttableview registerclass:[uitableviewcell class] forcellreuseidentifier:@"cell"]; dispatch_async(dispatch_get_main_queue(), ^{ [lefttableview selectrowatindexpath:[nsindexpath indexpathforrow:0 insection:0] animated:yes scrollposition:uitableviewscrollpositionnone]; }); } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { uitableview *righttableview = (uitableview *)[self viewwithtag:1]; switch (tableview.tag) { case 0: { self.right = self.left[indexpath.row][@"subchild"]; dispatch_async(dispatch_get_main_queue(), ^{ [righttableview reloaddata]; }); } break; } }
dispatch_async(dispatch_get_main_queue(), ^{ [lefttableview selectrowatindexpath:[nsindexpath indexpathforrow:0 insection:0] animated:yes scrollposition:uitableviewscrollpositionnone]; });
execute method after delay. may you.
Comments
Post a Comment