0

在我的 appdelagate 我有这个:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


    MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController_iPhone" bundle:nil];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
    self.window.rootViewController = self.navigationController;

[self.window makeKeyAndVisible];
return YES;
}

我有一个 masterview 和 detailview,masterview 是一个表格,当我在 masterview 中单击一行时会推送到 detailview,但是我添加到 detailview 的 barbutton 项目不会显示。它看起来像这样:

DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController_iPhone" bundle:nil];

[self.navigationController pushViewController: detailViewController animated:YES];
4

1 回答 1

0

我将提供您正在做的事情的替代方案,因为我不确定为什么您的项目没有显示。我的猜测是,在您推送视图控制器后,detailViewController中的导航栏被它的干净副本覆盖。

-viewDidLoad()方法中,在detailViewController.m中手动添加 UIBarButtonItem。

// 创建一个标准的保存按钮 UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]

              initWithBarButtonSystemItem:UIBarButtonSystemItemSave
              target:self
              action:@selector(saveAction:)];

saveButton.style = UIBarButtonItemStyleBordered;  
[buttons addObject:saveButton];  
[saveButton release];

于 2012-09-04T23:50:25.347 回答