简体   繁体   English

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

[英]Push a view controller from root to detail view controller (SplitView)

My splitview contains UITable (Masterview) and tabbar with navigationcontroller on each tabbaritem (Detailview). 我的splitview包含UITable(Masterview)和带有导航控件的选项卡,每个选项卡上的选项卡(Detailview)。 What I want to have is when I click on tablerow in Masterview, it will push a new view in detail view controller. 我要拥有的是当我单击Masterview中的tablerow时,它将在详细视图控制器中推送一个新视图。

I wrote this iteration to get the right UINavigationController and push the new view. 我编写了此迭代以获取正确的UINavigationController并推送新视图。 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 干杯,Inoel

Try to replace 尝试更换

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

with this: 有了这个:

[curController pushViewController:pdfViewerController animated:YES];

Because curController is already object of UINavigationController class 因为curController已经是UINavigationController class对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将活动指示器添加到splitview控制器的详细视图中 - Adding activity indicator to the detail view of a splitview controller 限制从详细视图控制器显示根视图控制器 - restrict showing root view controller from the detail view controller 如何从详细视图 controller 以编程方式推送视图 controller - How to push a view controller programmatically from Detail view controller 使用导航控制器从mapView推送详细视图 - Push a detail view from mapView with a Navigation Controller swift splitview控制器显示详细视图,即使它是空的 - swift splitview controller showing detail view even though it is empty 在UIStoryboard中按下到根视图控制器 - Push to root View controller in UIStoryboard 如何从主视图控制器在详细视图控制器中推送新视图? - How to push new view in detail view controller from master view controller? 如何将字幕从uitableview推送到详细视图控制器 - how to push subtitle from uitableview to detail view controller iPad SplitViewController:从详细视图控制器重新加载根视图控制器的表视图 - iPad SplitViewController: Reloading the root view controller's tableview from the detail view controller 从呈现视图控制器推送视图控制器 - Push View Controller from Presenting View Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM