2009-07-10 69 views
0

我有下面的代码在我的应用程序显示一个模式的看法:我的导航栏中不需要的编辑按钮?

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]; 

然而,当我运行,而不是在我的导航栏右侧完成按钮我有一个编辑按钮。如果我将.rightBarButton更改为.leftBarButton,我的完成按钮出现在左侧,但编辑按钮再次出现在右侧。

我是否应该特意在代码中删除这个不需要的编辑按钮,还是我在做错误的事情,使它出现在第一个地方?如果我必须删除它,我该如何去做?

回答

3

确保在InfoTableViewController的-viewDidLoad方法中没有将右侧按钮设置为编辑按钮。

在默认的UITableViewController子类存根代码中,有一条注释掉的行来执行此操作。也许你不小心取消了评论?

在-viewDidLoad中设置它将在你已经在你的包含代码中设置它之后执行,因为该方法在viewController实际加载(即,当你以模态方式呈现)之前不会运行。

+0

啊,那就是问题了。我不敢相信我没有看到!非常感谢。 – 2009-07-12 03:49:26