UIBarButtonItems
我的导航控制器上有两个:
segmentControl = UISegmentedControl(items: ["Up", "Down"])
infoItem = UIBarButtonItem(image: infoImage,
style: .plain,
target: self,
action: #selector(infoAction))
navigationItem.rightBarButtonItems = [infoItem, UIBarButtonItem(customView: segmentControl)]
当点击infoItem
我做:
@objc func infoAction()
{
let popoverContentController = InfoViewController()
popoverContentController.preferredContentSize = CGSize(width: 300, height: 300)
popoverContentController.modalPresentationStyle = .popover
popoverContentController.popoverPresentationController?.delegate = self
popoverContentController.popoverPresentationController?.passthroughViews = nil
self.present(popoverContentController, animated: true, completion: nil)
}
然后调用UIPopoverPresentationControllerDelegate
函数:
func prepareForPopoverPresentation(_ popoverPresentationController: UIPopoverPresentationController)
{
popoverPresentationController.permittedArrowDirections = .any
popoverPresentationController.barButtonItem = infoItem
popoverPresentationController.passthroughViews = nil
}
func adaptivePresentationStyle(for controller: UIPresentationController,
traitCollection: UITraitCollection) -> UIModalPresentationStyle
{
return .none
}
即使我设置passthroughViews
为nil
两次,UISegmentedControl
当弹出框出现在屏幕上时,它也不会脱色并且仍然可以点击。
如果显示任何其他弹出框,则UISegmentedControl
行为正常:已脱色且不可点击。
我在这里想念什么?