2012-08-16 89 views
0

我有一個Master-Detail應用程序。當用戶在MasterTable中選擇一行時,我想打開另一個Table(而不是DetailViewController)。它應該除了MasterViewController之外,與iPad上的Facebook應用類似。在故事板中自定義segue

我有一個從MasterViewController到這個表(DocumentViewController類型爲UITableViewController)的自定義segue。此DocumentViewController在導航控制器中是「嵌入的」。

總之,在我的故事板看起來像這樣的項目:

navigationController-> MasterViewController-> navigationController-> DocumentViewController。

segue從MasterViewController到navigationController。

我是否必須在「didSelectRowAtIndexPath」中執行segue?或者我必須在didSelectRowAtIndexPath中使用「performSegueWithIdentifier」嗎?

回答

1

如果我正確理解你的問題,segue應該從MasterViewController到DocumentViewController。確保給它一個唯一的標識符,然後在您的MasterViewController中引用您想要在prepareForSegue中執行的操作。

例子:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([[segue identifier] isEqualToString:@"showList"]) { 

     // gets indexPath for the currently selected row in my UITableView 
     NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 

     // pull back some useful data from Core Data according to what was selected in my UITableView. 
     NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath]; 

     // listDataItem is a property of the controller (in this case a UITableViewController) 
     [[segue destinationViewController] setListDataItem:object]; 
    } 
} 
+0

這將幫助我把數據發送到DocumentViewController.But我如何「動畫」的SEGUE所以MasterVC向左移動和DocumentVC坐在除了MasterVC? – user1550951 2012-08-16 06:54:03

+0

@NetToiOS,這可能是一個很好的起點:http://stackoverflow.com/questions/9348605/custom-segue-with-uiviewanimationoptiontransitioncurldown。另外,如果這有幫助,請接受答案。 – FilmJ 2012-08-16 06:58:33

+0

該示例使用UIViewController,可以使用UITableViewController,因爲那是什麼MasterViewController和DocumentViewController?並且...我已經接受了答案:) – user1550951 2012-08-16 07:11:39