0

I would like to present a popover from UIBarButtonItem present in UITabBarController using objectiveC in iOS9. This popover is a UITableViewController. I have coded it in the following way

- (IBAction)MenuButtonPopOverTouch:(id)sender {
LogoutTableViewController* content = [[LogoutTableViewController alloc] init];
content.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:content animated:YES completion:nil];
UIPopoverPresentationController *PopOverPresentation = [content popoverPresentationController];
PopOverPresentation.permittedArrowDirections = UIPopoverArrowDirectionDown;
}

I think i have missed the content size of the popover but don't know how to initialize it. Any help is appreciated. Attaching a preview of my storyboard if needed anything else please let me know

storyboardImage

arun_K
  • 313
  • 1
  • 4
  • 12
  • create invisible uiview over the tabbarcontroller's tabbar. You have to subclass UITabBarController. then, assign a long press gesture recognizer to this invisible view. Then when the user taps the CGRect area and point of where you want the button that presents a popover, you intercept this event and then present popover instead. I do this all the time, lots of code to make it work, but this is the easiet way I've found. good luck – Larry Pickles Nov 19 '15 at 00:48
  • @Larcerax Sorry couldn't understand it properly as i am kind of newbie in this if possible can u provide me a code snippet... – arun_K Nov 19 '15 at 04:53

1 Answers1

0

I found answer to my question here is the solution

- (IBAction)MenuPopOver:(id)sender {

 [self performSegueWithIdentifier:@"CustomerMenu"    sender:self.MenuBarButtonItem];
 }

 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSString *popoverIdentifier = segue.identifier;
if([popoverIdentifier isEqualToString:@"CustomerMenu"]){
    UIViewController *dvc = segue.destinationViewController;
    dvc.preferredContentSize = CGSizeMake(150, 50);
    UIPopoverPresentationController *ppc = dvc.popoverPresentationController;
    if (ppc) {
        ppc.delegate = self;    
    }
}
}

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}

I found it through this link PopoverPresentationController

It has been tested as well

Community
  • 1
  • 1
arun_K
  • 313
  • 1
  • 4
  • 12