2015-11-06 97 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文檔。