0

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?

Benjamin Autin
  • 4,143
  • 26
  • 34
Sean R
  • 1,519
  • 2
  • 13
  • 16

1 Answers1

3

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
  • 11,943
  • 14
  • 73
  • 115