如何在Popoverview中添加UIBarButtonItem操作?

时间:2014-12-30 06:46:13

标签: ios uibarbuttonitem uipopover

我想用UIBarButtonItem动作显示popoverview但我无法在故事板中添加popover segue。因为我以编程方式添加了UIBarButtonItem。

谢谢你的回复。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

@property (nonatomic, strong) UIPopoverController *yourPopOverController;

在你的行动方法中。

 UIBarButtonItem *yourButton = (UIBarButtonItem *)sender;

 YourViewController *yourViewControllerObject = [[YourViewController alloc]init];

        yourPopOverController = [[UIPopoverController alloc] initWithContentViewController:yourViewControllerObject];
        yourPopOverController.delegate = self;
        [yourPopOverController presentPopoverFromBarButtonItem:yourButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];