如何以编程方式在 MonoTouch 的 UITableView 中选择一行? [英] How to programmatically select a row in UITableView in MonoTouch?

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

问题描述

我知道您可以通过调用 UITableView.SelectRow 函数在 UITableView 中选择一行,但是我无法为给定的行号构造第一个参数 NSIndexPath.这是我试过的代码:

I know you can select a row in a UITableView by calling UITableView.SelectRow function, but I'm having trouble to construct the first parameter NSIndexPath for the given row number. This is the code I tried:

NSIndexPath path = new NSIndexPath() { Row = 3 };
tableView.SelectRow(path, false, UITableViewScrollPosition.None);

但它无法编译,因为 Row 是只读的.

But it doesn't compile because Row is read-only.

或者也许有不同的方法来做到这一点?

Or maybe there is a different way to do it?

推荐答案

改用 NSIndexPath.FromRowSection 静态方法:

Use the NSIndexPath.FromRowSection static method instead:

NSIndexPath path = NSIndexPath.FromRowSection(3, 0);

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

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