2012-11-07 77 views
0

不太確定如何解釋這一點,但在我的UITableView我有一行代碼,當我點擊一個單元格時,它將帶我到一個新的視圖,它根據單元格的名稱更新它的標題。然而,如果我有兩個單元格,一個名爲'One',另一個名爲'Two',當我點擊'Two'時,它會將我帶到標題爲'One'的視圖,反之亦然。任何想法可能是造成這種情況的原因?對不起,我不能有更多的幫助。TableView加載錯誤的單元格

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    ACollection *newView = [[ACollection alloc] init]; 
    newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
    [self.navigationController pushViewController:newView animated:YES]; 
} 
+0

只顯示您的代碼段...我想它的邏輯問題 –

+1

提供更多的代碼.. w –

+0

請發佈'didSelectRowAtIndexPath'代碼:) –

回答

1

我想你已經選擇了錯誤的方法,該

剛剛嘗試這個代碼:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    ACollection *newView = [[ACollection alloc] init]; 
    newView.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
    [self.navigationController pushViewController:newView animated:YES]; 
} 
+0

我有謝謝你!只需注意取消選擇,謝謝 –

+0

隨時歡迎.... :) –

相關問題