ios - 获取 UIBarButtonItem 的框架

标签 ios frame uibarbuttonitem uipopover

我在 NavigationBar 中创建了一个 UIBarButtonItem:

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


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

现在我想从此按钮打开一个弹出窗口,但我无法获取 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];

谢谢!!

最佳答案

使用 presentPopoverFromBarButtonItem:permittedArrowDirections:animated:

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

关于ios - 获取 UIBarButtonItem 的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11841315/

相关文章:

cocoa - NSSplitView 中的 NSTableView 框架不正确

swift - 透明导航栏的栏按钮项

ios - 如何在 UILabel 中显示替代密码字符?

ios - Interface Builder 中的 Dead Outlets/Actions 错误

iOS:加载表格 View 时无法更新单元格中 View 的框架

ios - 在不使用自动布局的情况下调整 iOS 11 中的条形按钮项目

ios - 为什么我的 UIBarButtonItem 不调用我的自定义函数?

iphone - kAudioSessionProperty_InputSources 实际上有什么用?

iOS:导航栏标题 - 两种颜色

iphone - 使用 CGRectZero 框架将 UIView 放置在 UITableView 的中间