【发布时间】:2011-07-28 18:31:42
【问题描述】:
有没有办法确定 UITableView 的“顶部”部分标题是什么?
对于“顶部部分标题”,我指的是粘在 UITableView 边界顶部的部分标题。
【问题讨论】:
标签: iphone uitableview sections
有没有办法确定 UITableView 的“顶部”部分标题是什么?
对于“顶部部分标题”,我指的是粘在 UITableView 边界顶部的部分标题。
【问题讨论】:
标签: iphone uitableview sections
您可以使用以下方法获取部分编号:
NSUInteger sectionNumber = [tableView indexPathForCell: [[[tableView visibleCells] objectAtIndex: 0] section]];
希望对你有帮助。
【讨论】:
您需要使用 -(UIView) viewForHeaderInSection 方法。这将允许您使用自己的 UI 视图作为表格视图部分的标题。
【讨论】:
如果您指的是 TABLE 标头(和 TABLE 页脚),而不是 SECTION 页眉/页脚,那么您可以通过 tableHeaderView 访问它,这是 UITableView 的一个属性
tableHeaderView Returns an accessory view that is displayed above the table.
@property(nonatomic, retain) UIView *tableHeaderView
如果你想要SECTION头,那么你需要通过实现UITableViewDelegate方法-tableView:viewForHeaderInSection:来创建它
tableView:viewForHeaderInSection: Asks the delegate for a view object to display in the header of the specified section of the table view.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
【讨论】: