我想在 UIBarButtonItem
中将 View Controller 显示为 iPhone 中的弹出窗口
我在按钮的操作上编写了以下代码。
-(IBAction)showAvailableCategory:(UIButton *)sender
{
CategoryPopup *categoryPopupViewController = [[CategoryPopup alloc]init];
UIPopoverPresentationController *popOverCat = categoryPopupViewController.popoverPresentationController;
categoryPopupViewController.preferredContentSize = CGSizeMake(138, 122);
popOverCat.delegate = self;
popOverCat.sourceView = sender;
popOverCat.sourceRect = sender.bounds;
popOverCat.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:categoryPopupViewController animated:YES completion:nil];
}
我做了我的
CategoryPopup
作为 xib
中的自由格式而且我正在实现下面的委托(delegate)方法-(UIModalPresentationStyle) adaptivePresentationStyleForPresentationController: (UIPresentationController * ) controller
{
return UIModalPresentationNone;
}
但它不是作为弹出窗口出现而是全屏出现,有解决方法吗?
最佳答案
您只忘记了一项设置,请在 categoryPopupViewController
之后添加的初始化:
categoryPopupViewController.modalPresentationStyle = UIModalPresentationPopover;
关于ios - 从 iPhone 中的 UIBarButtonItem 呈现弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41691553/