我当前的TableView返回了五个项目。 项目:苹果,梨,香蕉,橙,芒果
我想知道如何获取所选行的值。例如,如果我点击Apple,则值为" Apple"
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
HelloViewController helloView = new HelloViewController(___________);
AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
appDelegate.RootNavigationController.PushViewController(helloView, true);
}
在那里有一个下划线,我想显示获取Value的方法。像GetRowValue(indexPath)之类的东西。非常感谢任何帮助。
答案 0 :(得分:0)
假设您的基础数据源是
List<Fruit> data;
然后在您的RowSelected方法中使用indexPath获取所选项:
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
var item = data[indexPath.Row];
HelloViewController helloView = new HelloViewController(item);
AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
appDelegate.RootNavigationController.PushViewController(helloView, true);
}