2012-03-11 83 views
0

我有一個表格視圖與每行中的標題。表視圖細節披露iOS

現在我需要當我點擊行時它應該帶我到下一個視圖(細節視圖)。

我已經連接了行和新的視圖與segue「信息細節塞格」。

現在,這裏是代碼:

if ([segue.identifier isEqualToString:@"Information Detail Segue"]) { 

    InformationDetailTVC *informationdetailTVC = segue.destinationViewController; 
    informationdetailTVC.managedObjectContext = self.managedObjectContext; 
    informationdetailTVC.delegate = self; 
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 
    self.selectedInformation = [self.fetchedResultsController objectAtIndexPath:indexPath]; 
    NSLog(@"Passing selected role (%@) to RoleDetailTVC", self.selectedInformation.title); 
    informationdetailTVC.information = self.selectedInformation; 
} 

但是,當我運行,並單擊單元格,控制不走這個循環。事實上,當我點擊單元格時,它變成藍色,並且不加載新視圖。

任何人都可以告訴我我錯過了什麼嗎?

+0

你寫這個代碼裏面didSelectRowAtIndexPath方法? – Lucas 2012-03-11 20:08:22

+0

nopes ...是否需要?我正在關注這個鏈接:http://timroadley.com/2012/02/14/core-data-basics-part-3-editing-and-deleting/並且這裏的代碼沒有這個功能。 – user1253637 2012-03-11 20:19:30

+0

我在prepareForSegue方法下編寫了這段代碼......但它並不僅僅在這個方法裏面。 – user1253637 2012-03-11 20:20:43

回答

0

嘗試實施:

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

不要忘記設置您的代理和數據源(通常是在廈門國際銀行文件)

+0

謝謝,我實現didSeleceRowAtIndexPath方法,它的工作。但我仍然想知道,爲什麼它不適合segue? – user1253637 2012-03-12 02:05:01