Paul
Paul

Reputation: 31

Change pop-over contentsize using navigationcontroller

I want to show a popover with a custom contentsize. I can do it doing like so

UINavigationController* popoverContent = [[UINavigationController alloc] init];


    UIView* popoverView = [[UIView alloc]  initWithFrame:CGRectMake(0, 0, 800, 800)];

    popoverView.backgroundColor = [UIColor blueColor];

    popoverContent.view = popoverView;

    popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);
    UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
    [pop presentPopoverFromRect:CGRectMake(80.0, 210.0, 160.0, 40.0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];

but if I change the content to :

popoverContent.viewControllers = [NSArray arrayWithObject:myViewController];

the

popoverContent.contentSizeForViewInPopover = CGSizeMake(55, 55);

the size doesn't change at all.

How can I change the content size while using the navigation controller? Thanks

Upvotes: 3

Views: 3642

Answers (1)

Martin Wickman
Martin Wickman

Reputation: 19905

Explicitly changing the popovers size works:

 [self.popoverController setPopoverContentSize:myView.size animated:YES];

But I agree that contentSizeForViewInPopover should work. It doesn't for me anyway.

Upvotes: 4

Related Questions