0

I have created an UIBarButtonItem inside a NavigationBar:

UIBarButtonItem *filtroFecha = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(filtrarFecha:)]autorelease];


    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects: addActivity, filtroFecha, nil];

Now I want to open a popover from this button, but I am not able to get the frame of the UIBarButtonItem.

if (_filtroActividadesView == nil) {
        self.filtroActividadesView = [[CRMFiltroActividadViewController alloc] init];
        _filtroActividadesView.delegate = self;
        self.filtroPopover = [[UIPopoverController alloc] 
                                  initWithContentViewController:_filtroActividadesView];               
    }

    [self.filtroPopover presentPopoverFromRect:CGRectMake(0, 0, 1400, 44) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

Thanks!!

javiazo
  • 1,892
  • 4
  • 26
  • 41

1 Answers1

4

Use presentPopoverFromBarButtonItem:permittedArrowDirections:animated:.

[self.filtroPopover presentPopoverFromBarButtonItem:filtroFecha
                    permittedArrowDirections:UIPopoverArrowDirectionUp
                    animated:YES];
zdtorok
  • 594
  • 1
  • 7
  • 21
featherless
  • 2,118
  • 19
  • 19
  • Beat me to it, while I was off getting the [relevant URL](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html). – Chris Aug 07 '12 at 08:04