Select uitableview row programmatically

后端 未结 2 618
既然无缘
既然无缘 2021-02-08 01:48

i have read a lot on this argument, i have tested this example that works: source code example. but this doesn\'t use storyboards (i don\'t know if this is the reason that make

2条回答
  •  我寻月下人不归
    2021-02-08 01:57

    - (void)viewDidLoad {
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
    }
    

    If you want the callback from the delegate:

    if ([self.tableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) {
        [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    }
    

提交回复
热议问题