1

我的 splitview 在每个 tabbaritem (Detailview) 上包含 UITable (Masterview) 和带有 navigationcontroller 的 tabbar。我想要的是当我在 Masterview 中单击 tablerow 时,它将在详细视图控制器中推送一个新视图。

我编写了这个迭代来获得正确的 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];

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

干杯, Inoel

4

1 回答 1

1

尝试更换

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

有了这个:

[curController pushViewController:pdfViewerController animated:YES];

因为curController已经是对象UINavigationController class

于 2011-08-31T14:06:08.637 回答