Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPopover without any arrows

Is it possible to present a popover without any sort of arrows pointing somewhere?

like image 338
David Liu Avatar asked Aug 03 '10 21:08

David Liu


6 Answers

Yes it is possible just do:

 [self.popoverController presentPopoverFromBarButtonItem:anItem   
                                permittedArrowDirections:0
                                                animated:YES];

The zero represent no direction.

like image 102
Matt Avatar answered Nov 10 '22 14:11

Matt


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
}
like image 38
Sachin Agarwal Avatar answered Nov 10 '22 13:11

Sachin Agarwal


Swift4:

popover.permittedArrowDirections = []              
like image 19
Alexey Malyarenko Avatar answered Nov 10 '22 12:11

Alexey Malyarenko


Set the permittedArrowDirections to 0.

permittedArrowDirections:0

Code -

[self.popoverController presentPopoverFromBarButtonItem:anItem   
                                permittedArrowDirections:0
                                                animated:YES];

Zero tells "NoDirection".

like image 11
Akshay Avatar answered Nov 10 '22 14:11

Akshay


Swift3, this code work for me

popover.permittedArrowDirections = .init(rawValue: 0)
like image 9
Khuong Avatar answered Nov 10 '22 14:11

Khuong


For Swift 2.0 and iOS9 the solution is:

popoverViewController?.permittedArrowDirections = UIPopoverArrowDirection()
like image 5
Nuno Vieira Avatar answered Nov 10 '22 13:11

Nuno Vieira