在故事板中自定义segue

问题描述:

我有一个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”吗?

如果我正确理解你的问题,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://*.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