How do I select a UITableViewCell by default?

前端 未结 7 2113
忘了有多久
忘了有多久 2020-12-17 10:50

I have created a UITableView and would like a specific UITableViewCell to appear selected (blue) when the view is loaded.

7条回答
  •  暖寄归人
    2020-12-17 11:18

    Use this code to select cell by default in table view, indexPath can be vary according to your need

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

提交回复
热议问题