我的splitview包含UITable(Masterview)和每个tabbaritem(Detailview)上带有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
答案 0 :(得分:1)
尝试替换
[curController.navigationController pushViewController:pdfViewerController animated:YES];
用这个:
[curController pushViewController:pdfViewerController animated:YES];
因为curController
已经是UINavigationController class