我正在提出一个像这样的模态弹出视图:
let popover = StatueSelectionController(collectionViewLayout: UICollectionViewFlowLayout())
popover.delegate = self
popover.modalPresentationStyle = .popover
popover.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
popover.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up;
popover.preferredContentSize = CGSize(width: 200, height: 300)
present(popover, animated: true, completion: nil)
popover.delegate = self
与UIPopoverControllerDelegate
无关,尽管它确实实现了该协议。
问题是popover占据了整个视图。 StatueSelectionController
UICollectionViewController
填满整个屏幕,preferredContentSize
不会更改。
我在这里做错了什么?
答案 0 :(得分:0)
如果您想强制popOver无法覆盖iPhone的全屏,则必须在代码中添加UIPopoverPresentationControllerDelegate
方法
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}