Search code examples
iosuibarbuttonitemuipopover

How to add UIBarButtonItem action in Popoverview?


i want to show popoverview with UIBarButtonItem action but i cannot add popover segue in storyboard. Because i added UIBarButtonItem programmatically.

Thanks in replies.

enter image description here

enter image description here


Solution

  • @property (nonatomic, strong) UIPopoverController *yourPopOverController;
    

    In your action Method.

     UIBarButtonItem *yourButton = (UIBarButtonItem *)sender;
    
     YourViewController *yourViewControllerObject = [[YourViewController alloc]init];
    
            yourPopOverController = [[UIPopoverController alloc] initWithContentViewController:yourViewControllerObject];
            yourPopOverController.delegate = self;
            [yourPopOverController presentPopoverFromBarButtonItem:yourButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];