我想从导航栏的标题中显示一个弹出窗口,该标题已成功配置为具有多个选项的按钮,例如iPhone应用程序上的警报控制器。点击标题时会调用以下代码,但它会在底部显示操作表而不是弹出窗口。你能帮我找到什么问题吗?感谢。
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];