在我的应用程序中,我展示了一个顶部带有导航栏的 modalViewController,但我无法将 barbuttons 添加到导航栏。我正在使用以下代码:
displayController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:displayController];
[displayController setTitle:@"TEST"];
UIBarButtonItem *submit = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.rightBarButtonItem = submit;
[submit release];
UIBarButtonItem *newsfeed = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(displayViewForPosts)];
displayController.navigationItem.leftBarButtonItem = newsfeed;
[newsfeed release];
[self presentModalViewController:cntrol animated:YES];
[cntrol release];
[displayController release];