获取UiTableView标头的索引路径?
问题描述:
有没有什么办法可以得到uitableview头的indexpath?获取UiTableView标头的索引路径?
我有以下代码:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
static NSString *CellIdentifier = @"cell";
LocationCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
[NSException raise:@"headerView == nil.." format:@"No cells with matching CellIdentifier loaded from your storyboard"];
}
如上委托方法,没有indexPath通过,可我得到头的indexpath?
答
UITableView
中的部分标题(或页脚)没有属性indexpath,但它确实提供了您在问题中显示的委托方法中当前section
的访问权限。
有关UITableViewHeaderFooterView类参考的表格视图页眉和页脚,请参阅Apple文档。
您可以在tableView:didSelectRowAtIndexPath方法中获取indexPath, –
您是否指头的indexPath.section? – anhtu
Anbu:当我点击标题单元格时,无法调用didSelect。 anhtu:没有,indexpath。 – Rendy