开发者

how to pushViewController to tabBarController view?

I'm trying to display a UIViewController which displays a pdf file (PDFReaderViewController). I have a tabBarController with 4 tabs. I want to select the 4th tab, which is a UITableView with a list of files, and display the pdf with a navigation bar at the top. When the user is done viewing the pdf he can navigate back to the UITableView (4th tab). I'm able to display the 4th tab view but I can't get it to display the pdf. Here is my code:

    PDFReaderViewController *pdfController = [[PDFReaderViewController alloc] init];
    [pdfController initwithName:fileName];

    //display the right tab view
    UIViewController *currView = [tabBarController.viewControllers objectAtIndex:3];    
    [tabBarController setSelectedViewController:currView];
    [window insertSubview:tabBarController.view atIndex:0];

    [[currVie开发者_如何转开发w navigationController] pushViewController:pdfController animated:YES];///this is not showing!!!!
    [currView loadView];

    [pdfController release];
    [window makeKeyAndVisible]; 

What am I doing wrong here? Thanks for your help!


My best guess is that currView is not a navigation controller.

You need to make the 4th tab be a navigation controller, whose root view controller is the tableView. I'm guessing [currView navigationController] is returning nil.

The best way to see this is to set a breakpoint at the relevant line, then open the debugger and type po currView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜