I have two UIBarButtonItems
on my navigation controller:
segmentControl = UISegmentedControl(items: ["Up", "Down"])
infoItem = UIBarButtonItem(image: infoImage,
style: .plain,
target: self,
action: #selector(infoAction))
navigationItem.rightBarButtonItems = [infoItem, UIBarButtonItem(customView: segmentControl)]
When tapping infoItem
I do:
@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)
}
This then calls out to UIPopoverPresentationControllerDelegate
functions:
func prepareForPopoverPresentation(_ popoverPresentationController: UIPopoverPresentationController)
{
popoverPresentationController.permittedArrowDirections = .any
popoverPresentationController.barButtonItem = infoItem
popoverPresentationController.passthroughViews = nil
}
func adaptivePresentationStyle(for controller: UIPresentationController,
traitCollection: UITraitCollection) -> UIModalPresentationStyle
{
return .none
}
Even though I set passthroughViews
to nil
twice, the UISegmentedControl
is not decolorized and remains tappable while the popover is on screen.
If showing any other popover the UISegmentedControl
behaves normally: decolorized and not tappable.
What am I missing here?