2013-08-06 40 views
2

我的表格相對簡單,與我之前完成的許多操作沒有根本的不同。然而didSelectRowAtIndexPath僅在表格的前5個單元格上調用。之後,當我點擊時,調試語句不會出現。我在這裏研究了這個問題,並排除了其他問題中提到的一些可能性: - 表代表正確設置。 - 一個GestureRecognizer(我已經設定)沒有吞下印刷機。 - willSelectRowAtIndexPath未實施didSelectRowAtIndexPath在前5個單元格後不調用

以下是我的didSelectRowAtIndexPath。讓我知道我還能提供什麼來幫助解決這個問題。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    NSLog(@"didSelect"); 
    NSArray *visibleCells = [partOfSpeechTable visibleCells]; 
    UITableViewCell *cell = [visibleCells objectAtIndex:indexPath.row]; 

    NSNumber *checkedState = [checkedStates objectAtIndex:indexPath.row]; 
    if ([checkedState boolValue]) 
    { 
     [cell setAccessoryType:UITableViewCellAccessoryNone]; 
     [checkedStates setObject:[NSNumber numberWithBool:NO] atIndexedSubscript:indexPath.row]; 
    } 
    else 
    { 
     [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 
     [checkedStates setObject:[NSNumber numberWithBool:YES] atIndexedSubscript:indexPath.row]; 
    } 

    [[tableView cellForRowAtIndexPath:indexPath] setSelectionStyle:UITableViewCellSelectionStyleNone]; 
} 

(我可以評論出所有的配件,它沒有區別)。

感謝您的任何幫助。

+0

是5個單元格中唯一沒有滾動可見的單元格嗎? –

+0

感謝您的評論,聖誕老人。其實,在放棄並張貼之後,我立刻找到了答案。我的桌子坐在另一個UIView中,我正在使用它來垂直滑動某些元素,並且UIView沒有足夠長的時間來容納表格。所以表格會全部顯示,但是表格部分超過了包含視圖的切斷點,並沒有響應用戶的交互。我會發布這個答案。 –

回答

6

原來,包含視圖比表本身更短。該表格完整顯示,但包含視圖的切斷下面的部分沒有響應用戶交互。解決方案是增加包含視圖的大小。

+0

如何增加包含視圖大小請幫助我在tableview中有同樣的問題。謝謝。 – ilesh

+0

謝謝傑森,我永遠搜索找到答案。 – turingtested

2

我也遇到過類似問題的種類及其可能因爲

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{  
     return 20; 
} 

設置單元格的大小,因此它可以適應視圖。

0

enter image description here

我有同樣的問題與傑森。在我的情況下,只有第一行的單元格沒有調用didSelectRowAtIndexPath。我增加了xib文件中tableview的包含視圖(或者你可以編程)。

相關問題