开发者

need help with UINavigationController

I have a class called CataloguesEtTarifsPDFViewController which displays a tableView. Now, inside this class I wanna create a UINavigationController and set the root of the UINavigationController this class:

Here is what I did:

CataloguesEtTarifsPDFViewController.h

 UINavigationController *navigationController;

in the implementation file

CataloguesEtTarifsPDFViewController.m

- (void)viewDidLoad
{

    CataloguesEtTarifsPDFViewController *catalog =[[CataloguesEtTarifsPDFViewController alloc] init];

    loadingView.hidden=YES;
   navigationController = [[UINavigation开发者_StackOverflow社区Controller alloc] initWithRootViewController:catalog];

}

When I click on the table cell I do this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    WebViewController *webViewController = [[WebViewController alloc] init];

    [self.navigationController pushViewController:webViewController animated:YES];

    [navigationController release];

}

But when I run and click on the tableView nothing happens...not view is showed up!!!Where am I going wrong?

IMPORTANT: I don't have a delegate file.Only CataloguesEtTarifsPDFViewController.h CataloguesEtTarifsPDFViewController.m and CataloguesEtTarifsPDFViewController.xib.

EDIT:

- (IBAction)showViewCataloguesEtTarifsPDF:(id)sender{
    // Remove view to middleView
    [mainMenuViewController removeViewsToMiddleView];
    // create view controller
    cataloguesEtTarifsPDFViewController = [[CataloguesEtTarifsPDFViewController alloc] init];
    cataloguesEtTarifsPDFViewController.mainMenuViewController = mainMenuViewController;

   // hide/show header button
    [mainMenuViewController.headerViewController showMainMenuButton];
    // highlight footer tabbar button
    [mainMenuViewController.footerViewController.footerTabBar setSelectedItem:mainMenuViewController.footerViewController.footerTabBarItemMyAudi];   
     UINavigationController*  navigationController = [[UINavigationController alloc] initWithRootViewController:cataloguesEtTarifsPDFViewController];
      [self presentModalViewController:navigationController animated:YES];
}


You should probably read this: http://www.iosdevnotes.com/2011/03/uinavigationcontroller-tutorial/ Or this: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457-CH1-SW1

Or watch this: http://peepcode.com/products/iphone-view-controllers-part-i

That'll give you the basics and you'll be well equipped to answer your question and fix your code :)

PS: You don't have to explicitly create and set a UINavigationController in your view controller. If the view controller is embedded within a navigation controller, the navigationController property of your view controller instance will automatically find it and return it.


What you're doing in viewDidLoad is wrong.

Wherever you are showing the CataloguesEtTarifsPDFViewController, you should wrap it in a UINavigationController there and show the UINavigationController instead.

This will make sure the navigationController property of UIViewController will be set.

In your tableView:didSelectRowAtIndexPath: method you should release the webViewController variable instead of the navigationController property.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜