2015-11-06 99 views
0

有没有什么办法可以得到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?

+0

您可以在tableView:didSelectRowAtIndexPath方法中获取indexPath, –

+0

您是否指头的indexPath.section? – anhtu

+0

Anbu:当我点击标题单元格时,无法调用didSelect。 anhtu:没有,indexpath。 – Rendy

回答

-2

UITableView中的部分标题(或页脚)没有属性indexpath,但它确实提供了您在问题中显示的委托方法中当前section的访问权限。

有关UITableViewHeaderFooterView类参考的表格视图页眉和页脚,请参阅Apple文档。