1

在我的应用程序中,我展示了一个顶部带有导航栏的 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];
4

1 回答 1

1
UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];

UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:detailViewController];

[detailViewController setTitle:@"TEST"];


UIBarButtonItem *submit = [[UIBarButtonItem alloc]
                           initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                           target:self
                           action:@selector(displayViewForPosts)];
detailViewController.navigationItem.rightBarButtonItem = submit;
[submit release];


[self.navigationController presentModalViewController:cntrol animated:YES];
[cntrol release];
于 2010-07-14T22:19:27.017 回答