ios - Storyboard中的自定义segue

标签 ios storyboard xcode4.3 segue

我有一个主从应用程序。当用户在 MasterTable 中选择一行时,我想打开另一个表(而不是 DetailViewController)。除了 MasterViewController 之外,它还应该是纸质的,类似于 iPad 上的 Facebook 应用程序。

我有一个从 MasterViewController 到此表的自定义序列(UITableViewController 类型的 DocumentViewController)。此 DocumentViewController “嵌入”在导航 Controller 中。

简而言之,我的 Storyboard上的项目如下所示:

navigationController->MasterViewController->navigationController->DocumentViewController.

segue 是从 MasterViewController 到 navigationController。

我必须在“didSelectRowAtIndexPath”中执行转场吗?或者我是否必须在 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];
    }
}

关于ios - Storyboard中的自定义segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11981731/

相关文章:

ios - MKLocalSearch 未找到附近所有餐厅

ios - UIcollectionview支持覆盖流

iOS,应该如何备份导航堆栈而不是root?

ios - 如何设置导航栏的后退箭头?

xcode - 为什么我的 gcc 不在/usr/bin/gcc 中,即使安装了 Xcode 4.3?

ios - 核心数据对象注入(inject)(带有依赖项) Storyboard

objective-c - 在 Documents 或 Caches 文件夹中使用 iOS 文件名设备修饰符(~ipad、~iphone)

Storyboardsegue 显示从底部垂直而不是水平的过渡

ios5 - 命令行库构建失败,链接器错误

ios - 警报 View 按钮