Jos*_*ane 1 iphone objective-c uitableview ipad
我需要以编程方式选择UITableViewCell,我试过这个:
NSIndexPath *selectedCellIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[table selectRowAtIndexPath:selectedCellIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
Run Code Online (Sandbox Code Playgroud)
但是,它只能直观地选择单元格,didSelectRowAtIndexPath除非您实际点击单元格,否则不会选择该单元格.
任何想法,有没有人经历过这个或有想法绕过这个或以不同的方式处理它?
在向selectRowAtIndexPath发送消息后,为什么不向didSelectRowAtIndexPath发送消息?代码应该如下所示:
NSIndexPath *selectedCellIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[table selectRowAtIndexPath:selectedCellIndexPath
animated:YES
scrollPosition:UITableViewScrollPositionNone];
[table.delegate tableView:table didSelectRowAtIndexPath:selectedCellIndexPath];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2154 次 |
| 最近记录: |