Я хочу показать popover из заголовка навигационной панели, который успешно настроен как кнопка с несколькими вариантами, такими как Alert Controller в приложении iPhone. Следующий код вызывается, когда заголовок используется, но он показывает лист действий внизу, а не popover. Можете ли вы помочь мне найти, что случилось? Благодарю.Как представить UIAlertController в Popover для iPhone с iOS 8
UIAlertController * alertController = [UIAlertController alertControllerWithTitle: nil
message: nil
preferredStyle: UIAlertControllerStyleActionSheet];
[alertController addAction: [UIAlertAction actionWithTitle:@"Close" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// dismiss viewcontroller
[self dismissViewControllerAnimated:YES completion:nil];
}]];
[alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// Handle Cancel
// do nothing
}]];
alertController.modalPresentationStyle = UIModalPresentationPopover;
alertController.preferredContentSize = CGSizeMake(250.0, 180.0);
UIPopoverPresentationController *popoverPresentation = alertController.popoverPresentationController;
popoverPresentation.sourceRect = self.parentViewController.navigationItem.titleView.frame;
popoverPresentation.sourceView = self.view;
popoverPresentation.permittedArrowDirections = UIPopoverArrowDirectionUp;
popoverPresentation.delegate = self;
[self presentViewController: alertController animated: YES completion: nil];