在UITableView中选择First Row作为默认值 [英] Select First Row as default in UITableView

查看:73
本文介绍了在UITableView中选择First Row作为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于视图的应用程序,我将tableview作为子视图添加到主视图中。我已经使用 UITableViewDelegate 来响应表方法。一切正常,但我想选择第一行或 UITableView 作为默认选择(突出显示)。

I have an application that is viewbased and I am adding a tableview as a subview to the main view. I have taken UITableViewDelegate to respond the table methods. Everything is working fine, but I want to select the first row or UITableView as default selected(Highlighted).

请帮助我,我需要什么代码以及我需要放在哪里。

Please help me, with what code I need and where I need to put it.

推荐答案

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
    [myTableView selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionBottom];
}

在代码中使用此功能的最佳方式,如果您想选择任何默认情况下,在viewDidAppear中使用。

The best way to use this in your code, if you want to select any row by default, use in viewDidAppear.

这篇关于在UITableView中选择First Row作为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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