Как я могу добраться до UIToolbar текущего представления - PullRequest
4 голосов
/ 15 сентября 2011

У меня есть приложение на основе контроллера навигации, и я добавил несколько элементов панели инструментов с кодом в viewDidLoad:

NSArray* toolbarItems = [NSArray arrayWithObjects:
                         [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
                                                                       target:self
                                                                       action:@selector(addButton)],
                         [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                                                                       target:self
                                                                       action:nil],
                         [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose 
                                                                       target:self
                                                                       action:@selector(composeMail)],
                         nil];
[toolbarItems makeObjectsPerformSelector:@selector(release)];
self.toolbarItems = toolbarItems;

теперь я хочу показать actionSheet с [UIActionSheet showFromToolbar:], и для этого я хочу UIToolbar *, как я могу получить созданный ранее UIToolbar?

1 Ответ

4 голосов
/ 15 сентября 2011

Полагаю, вы имеете в виду «текущего контроллера представления».В этом случае вы хотите self.navigationController.toolbar.

...