I want to have a small UItableView that popup when clicked and shows some numbers in the list.
I tried to use popoverPresentationController but it appears full screen for iOS(iPhone) devices.
below is the code for same -
let filterVC = TableViewController(nibName: "TableViewController", bundle: nil)
filterVC.preferredContentSize = CGSize(width: 300, height: 200)
filterVC.modalPresentationStyle = UIModalPresentationStyle.popover
present(filterVC, animated: true, completion: nil)
let popoverPresentationController = filterVC.popoverPresentationController
if let pop = filterVC.popoverPresentationController {
pop.delegate = self
}
popoverPresentationController?.sourceView = sender as? UIView
popoverPresentationController?.sourceRect = sender.frame
//-------
with below method also
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
// Return no adaptive presentation style, use default presentation behaviour
return .none
}
//----- Any hint in right direction would be highly appreciated. working sample would be greatly helpful
What I am trying to achieve as below
UPDATE
There is a useful library you may want to give a try.
It's because your
pop.delegate
was assigned after you present thefilterVC
.Move this
to the init of your
filterVC
should do the trick. Btw, I didn't see anywhere you have assignedsourceView
andsourceRect
for yourpopoverPresentationController
. Movingpop.delegate = self
to this part should be appropriate. Something like