Is it possible to present a popover without any sort of arrows pointing somewhere?
Yes it is possible just do:
[self.popoverController presentPopoverFromBarButtonItem:anItem
permittedArrowDirections:0
animated:YES];
The zero represent no direction.
For iPhone and swift 2.0 try this one
Code to initiate popover
initiatePopover(){
let popoverContent = self.storyboard?.instantiateViewControllerWithIdentifier("XYZController") as! XYZController
let nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = nav.popoverPresentationController
popoverContent.preferredContentSize = CGSizeMake(250 ,200)
popover!.delegate = self
popover!.sourceView = self.view
popover!.sourceRect = CGRectMake(200,200,0,0)
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.presentViewController(nav, animated: true, completion: nil)
}
And add this to your ViewController
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
Swift4:
popover.permittedArrowDirections = []
Set the permittedArrowDirections
to 0.
permittedArrowDirections:0
Code -
[self.popoverController presentPopoverFromBarButtonItem:anItem
permittedArrowDirections:0
animated:YES];
Zero tells "NoDirection".
Swift3, this code work for me
popover.permittedArrowDirections = .init(rawValue: 0)
For Swift 2.0
and iOS9
the solution is:
popoverViewController?.permittedArrowDirections = UIPopoverArrowDirection()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With