我有一个Master-Detail应用程序。当用户在MasterTable中选择一行时,我想打开另一个Table(而不是DetailViewController)。除了MasterViewController之外,它应该是纸张,类似于iPad上的Facebook应用程序。
我有一个从MasterViewController到此表的自定义segue(类型为UITableViewController的DocumentViewController)。此DocumentViewController在导航控制器中是“嵌入式”。
简而言之,我的故事板上的项目如下所示:
navigationController-> MasterViewController-> navigationController-> DocumentViewController
segue是从MasterViewController到navigationController。
我是否必须在“didSelectRowAtIndexPath”中执行segue?或者我必须在didSelectRowAtIndexPath中使用“performSegueWithIdentifier”吗?
答案 0 :(得分: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];
}
}