自定义Popover TableView

时间:2018-01-16 03:54:55

标签: ios swift uicollectionview popover modalpopup

我正在提出一个像这样的模态弹出视图:

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 = selfUIPopoverControllerDelegate无关,尽管它确实实现了该协议。

问题是popover占据了整个视图。 StatueSelectionController UICollectionViewController填满整个屏幕,preferredContentSize不会更改。

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

如果您想强制popOver无法覆盖iPhone的全屏,则必须在代码中添加UIPopoverPresentationControllerDelegate方法

func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    return .none
}