I see that a similar question was asked here: How to add the right button in the UINavigationController? (among others), but this is not exactly what I am looking to do and they do not solve my problem.
Essentially, I created a UIViewController called WebViewViewController, with a UIWebView on it, which will be shown using presentModalViewController. In essence, it is a mini browser for displaying a web page, while the user is in the application instead of launching Safari.
ViewController does the following to show it ... and the "done" button is designed to provide a place to close the browser.
-(IBAction)visitFacebook { WebViewViewController *rootController = [[WebViewViewController alloc] init]; rootController.webURL = @"http://www.facebook.com/"; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootController]; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(done:)]; [navigationController.navigationItem setRightBarButtonItem:doneButton animated:YES]; [navigationController.navigationItem setTitle:@"Facebook"]; if (rootController) { [self presentModalViewController:navigationController animated:YES]; } [doneButton release]; [rootController release]; }
Unfortunately, the "done" button does not show .. any ideas that I'm wrong in?
source share