将视图控制器从根视图控制器推送到详细视图控制器(SplitView)

发布于 2024-12-02 04:56:13 字数 1098 浏览 0 评论 0原文

我的 splitview 包含 UITable (Masterview) 和每个 tabbaritem (Detailview) 上带有导航控制器的选项卡栏。我想要的是,当我单击 Masterview 中的表行时,它将在详细视图控制器中推送一个新视图。

我编写此迭代是为了获取正确的 UINavigationController 并推送新视图。不幸的是这不起作用。它不显示新视图,有时甚至会崩溃。

    // code from MasterView
    PDFViewer *pdfViewerController = [[PDFViewer alloc] initWithNibName:@"PDFViewer" bundle:nil];
    pdfViewerController.pdfData = [[NSData alloc] initWithData: pdfContent];
    pdfViewerController.docInfo = curDocInfo;

    // gets tabbar controllers
    XtendisAppDelegate *appDelegate = (XtendisAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSMutableArray *controllers = [NSMutableArray arrayWithArray: appDelegate.tabBarController.viewControllers];

    for (UIViewController *curController in controllers) {
        if ([curController isKindOfClass:[UINavigationController class]]) {
            [curController.navigationController pushViewController:pdfViewerController animated:YES];
            break;
        }
    }

    [pdfViewerController release];

知道我做错了什么吗? 任何帮助表示赞赏。提前致谢。

干杯, 伊诺尔

My splitview contains UITable (Masterview) and tabbar with navigationcontroller on each tabbaritem (Detailview). What I want to have is when I click on tablerow in Masterview, it will push a new view in detail view controller.

I wrote this iteration to get the right UINavigationController and push the new view. Unfortunately this doesn't work. It doesn't show the new view and sometimes it just crashed.

    // code from MasterView
    PDFViewer *pdfViewerController = [[PDFViewer alloc] initWithNibName:@"PDFViewer" bundle:nil];
    pdfViewerController.pdfData = [[NSData alloc] initWithData: pdfContent];
    pdfViewerController.docInfo = curDocInfo;

    // gets tabbar controllers
    XtendisAppDelegate *appDelegate = (XtendisAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSMutableArray *controllers = [NSMutableArray arrayWithArray: appDelegate.tabBarController.viewControllers];

    for (UIViewController *curController in controllers) {
        if ([curController isKindOfClass:[UINavigationController class]]) {
            [curController.navigationController pushViewController:pdfViewerController animated:YES];
            break;
        }
    }

    [pdfViewerController release];

Any idea what did i do wrong?
Any help appreciated. Thank's in advance.

Cheers,
Inoel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿得七秒忆 2024-12-09 04:56:13

尝试

[curController.navigationController pushViewController:pdfViewerController animated:YES];

用这个替换:

[curController pushViewController:pdfViewerController animated:YES];

因为 curController 已经是 UINavigationController 类 的对象

Try to replace

[curController.navigationController pushViewController:pdfViewerController animated:YES];

with this:

[curController pushViewController:pdfViewerController animated:YES];

Because curController is already object of UINavigationController class

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文