Created a SingleViewApplication in that I have placed a button.
Now clicking on button I need to display a tableView as popover. The TableViewController is created in xib.
The issue is tableViewController.popoverPresentationController always comes as nil see below code
let filterVC = TableViewController(nibName: "TableViewController", bundle: nil)
var filterDistanceViewController = UINavigationController(rootViewController: filterVC)
filterDistanceViewController.preferredContentSize = CGSize(width: 300, height: 200)
let popoverPresentationViewController = filterDistanceViewController.popoverPresentationController
popoverPresentationViewController?.permittedArrowDirections = .any
if let pop = filterDistanceViewController.popoverPresentationController {
pop.delegate = self
}
in above code filterDistanceViewController.popoverPresentationController is always coming as nil
Any hint in right direction will be highly appreciated.
Until you've set a
modalPresentationStyle
on your VC, thepopoverPresentationController
property will benil
. Ensure that you set themodalPresentationStyle
before accessing.You are not presenting anything, so you need to present the
popoverPresentationViewController
on the current viewcontroller, for example:You may do like below.