javiazo
javiazo

Reputation: 1982

Get frame of an UIBarButtonItem

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!!

Upvotes: 0

Views: 1523

Answers (1)

featherless
featherless

Reputation: 2141

Use presentPopoverFromBarButtonItem:permittedArrowDirections:animated:.

[self.filtroPopover presentPopoverFromBarButtonItem:filtroFecha
                    permittedArrowDirections:UIPopoverArrowDirectionUp
                    animated:YES];

Upvotes: 4

Related Questions