Добавьте кнопки bar на панель навигации с помощью modalView iphone - PullRequest
1 голос
/ 14 июля 2010

В моем приложении я представляю modalViewController с навигационной панелью вверху, но я не могу добавить кнопки на навигационную панель.Я использую следующий код:

РЕДАКТИРОВАТЬ:

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

Заранее спасибо.

1 Ответ

1 голос
/ 15 июля 2010
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];
...