【问题标题】:particular section should go to the top of the tableview特定部分应位于表格视图的顶部
【发布时间】:2013-09-27 09:25:03
【问题描述】:

我有一个UITableview,在其中我使用viewForHeaderInSection 方法像下拉菜单一样自定义视图,因此当我选择节标题视图上的特定按钮时,行的单元格看起来像下拉菜单。我需要一种方法,这样当我选择特定部分时,该部分应该转到表格视图的顶部。

有解决方案来实现吗?

【问题讨论】:

标签: iphone ios ipad uitableview


【解决方案1】:

首先根据下拉选择获取部分。

CGRect rect = [tableView rectForHeaderInSection:(NSInteger)section];

[tableView setContentOffset:CGPointMake(0.0, rect.origin.y)
             animated:YES];  

[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section]                                                
               atScrollPosition:UITableViewScrollPositionTop
                       animated:YES];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 2015-11-01
    相关资源
    最近更新 更多