UIToolbar Предметы не отображаются в поповере - PullRequest
4 голосов
/ 03 апреля 2012

Я пытаюсь отобразить пользовательский вид таблицы внутри всплывающего окна в моем приложении для iPad. Это работает нормально. Я хотел добавить кнопки на панели инструментов (внизу таблицы). Панель инструментов отображается пустой. Любое предложение?

Обратите внимание, что следующий код срабатывает, когда пользователь касается кнопки в контроллере основного вида.

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.customTableViewController];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"item 1" style:UIBarButtonItemStylePlain target:nil action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"item 2" style:UIBarButtonItemStylePlain target:nil action:nil];

[navigationController setToolbarHidden:NO];
navigationController.navigationBar.topItem.title = @"Some Title";

NSArray *array = [[NSArray alloc] initWithObjects:item1, item2, nil];
[navigationController setToolbarItems:array];

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
self.popoverController = popover;
popoverController.delegate = self;

[popoverController presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Ответы [ 2 ]

3 голосов
/ 24 мая 2012

Я сталкиваюсь с подобной проблемой, вид таблицы хорошо отображается в всплывающем окне, но кнопки ниже не видны.Я дам вам знать, если я что-нибудь выясню.

РЕДАКТИРОВАТЬ: Моя проблема была в том, что я изменил размеры поповера, и кнопки были вытеснены из вида.Я исправил это, изменив авторазмер, чтобы зафиксировать положение относительно нижней части кадра.Чтобы сделать это, посмотрите на свой xib в конструкторе интерфейсов, перейдите на вкладку Ruler в верхнем правом углу и используйте графический интерфейс Autosizing.Для меня это означало, что в графическом интерфейсе был выбран только нижний якорь.

2 голосов
/ 17 октября 2013

В приложениях для ipad вы должны установить элементы панели инструментов в "topViewController" (да, это нелогично).

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:catView];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"item 1" style:UIBarButtonItemStylePlain target:nil action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"item 2" style:UIBarButtonItemStylePlain target:nil action:nil];
[nav setToolbarHidden:NO animated:YES];
// WRONG: [nav setToolbarItems:[NSArray arrayWithObjects:addButton, nil]];
// CORRECT (for ipad apps):
[nav.topViewController setToolbarItems:[NSArray arrayWithObjects:item1, item2, nil] animated:NO];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:nav];

См .: http://www.kevatron.co.uk/tag/uipopovercontroller/

...