views:

369

answers:

1

Hi, I've got the following code in my app to display a modal view:

InfoTableViewController *infoTableViewController = [[[InfoTableViewController alloc] initWithNibName:nil bundle:nil] autorelease];
infoTableViewController.title = @"Pirateometer";
infoTableViewController.navigationItem.rightBarButtonItem =
 [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
  target:self action:@selector(dismissInfo)] autorelease];

navController = [[UINavigationController alloc] initWithRootViewController:infoTableViewController];
[self presentModalViewController:navController animated:YES];
[navController retain];

However when I run, instead of the Done button on the right of my navigation bar I have an Edit button. If I change .rightBarButton to .leftBarButton my Done button appears on the left as expected, but the Edit button is again there on the right.

Am I supposed to specially remove this unwanted Edit button in code, or am I doing something wrong that is making it appear in the first place? If I have to remove it, how do I go about doing so?

+2  A: 

Make sure in your -viewDidLoad method of InfoTableViewController that you're not setting the right button to the edit button.

In the default UITableViewController subclass stub code, there is a commented out line which does this. Perhaps you've accidentally uncommented it?

Setting it in -viewDidLoad will execute after you've already set it in your included code here, as the method doesn't run until the viewController is actually loaded (ie when you present it modally).

jbrennan
Ah, that was the problem exactly. I can't believe I didn't see that! Thanks very much.
Sean R