以编程方式选择tableview行 [英] Select tableview row programmatically

查看:117
本文介绍了以编程方式选择tableview行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式选择 UITableView 行,使

How do I programmatically select a UITableView row so that

- (void)tableView:(UITableView *)tableView 
        didSelectRowAtIndexPath:(NSIndexPath *)indexPath

执行? selectRowAtIndexPath 将只突出显示该行。

gets executed? selectRowAtIndexPath will only highlight the row.

推荐答案

参考文档

调用此方法不会导致
委托接收到
tableView:willSelectRowAtIndexPath:或
tableView:didSelectRowAtIndexPath:
消息,也不会发送
UITableViewSelectionDidChangeNotification
通知给观察者。

Calling this method does not cause the delegate to receive a tableView:willSelectRowAtIndexPath: or tableView:didSelectRowAtIndexPath: message, nor will it send UITableViewSelectionDidChangeNotification notifications to observers.

我会做的是:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self doSomethingWithRowAtIndexPath:indexPath];
}

然后,从你想调用selectRowAtIndexPath的地方调用doSomethingWithRowAtIndexPath。此外,如果您希望UI反馈发生,您还可以调用selectRowAtIndexPath。

And then, from where you wanted to call selectRowAtIndexPath, you instead call doSomethingWithRowAtIndexPath. On top of that, you can additionally also call selectRowAtIndexPath if you want the UI feedback to happen.

这篇关于以编程方式选择tableview行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆