我在使用作为 UITextView 附件视图的 UIBarbuttonItem 的 sourceView 呈现弹出视图时遇到困难。似乎键盘内的视图在某种程度上与视图层次结构中的其他视图不同。当我结束键盘编辑时,弹出视图出现在底层视图控制器的视图中。这是一些代码:
@objc func foregroundColorPressed(button : UIBarButtonItem)
{
let colorSelectionPopup = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ColorSelectionPopup")
colorSelectionPopup.modalPresentationStyle = .popover
let popOver = colorSelectionPopup.popoverPresentationController!
colorSelectionPopup.preferredContentSize = CGSize(width: 200, height: 100)
popOver.delegate = self
popOver.permittedArrowDirections = .up
popOver.barButtonItem = button
//popOver.sourceView = button.theView
//popOver.sourceRect = (button.theView?.bounds)!
getCurrentViewController()?.present(colorSelectionPopup, animated: true, completion: {
//
})
我的 popoverPresentationDelegate 方法是
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.none
}
我想要实现的目标是可能的吗?非常感谢任何帮助!