Select First Row as default in UITableView

后端 未结 11 1732
悲哀的现实
悲哀的现实 2021-01-30 20:12

I have an application that is viewbased and I am adding a tableview as a subview to the main view. I have taken UITableViewDelegate to respond the table methods.

11条回答
  •  隐瞒了意图╮
    2021-01-30 20:33

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
        [myTableView selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionBottom];
    }
    

    The best way to use this in your code, if you want to select any row by default, use in viewDidAppear.

提交回复
热议问题