iosobjective-cuipopovercontrolleruibarbuttonitemuipopover

iOS Present Popover from bar button item bottom


I have an UIPopoverController that presents an UIViewController using this method:

[self.popover presentPopoverFromBarButtonItem:self.infoBarButtonItem 
                     permittedArrowDirections:UIPopoverArrowDirectionUp
                                     animated:YES];

self.popover is my UIPopoverController.

The code works well, but the Popover arrow is in the middle of the BarButtonItem how do I display the Popover with its arrow "under" the button?

This is what it currently looks like:
altText


Solution

  • How about this

    UIBarButtonItem *item = self.infoBarButtonItem ;
    
    UIView *view = [item valueForKey:@"view"];
    
    if(view){
    
            CGRect frame=view.frame;
    
            [self.popover presentPopoverFromRect:frame
                                          inView:view.superview
                        permittedArrowDirections:UIPopoverArrowDirectionUp
                                        animated:YES];
    
    
    
    }