2

I've got a popover segue in my iPad storyboard. The popover contains a Nav Controller which contains my View Controller. I set the preferredContentSize in my View Controller and tried setting the Nav Controller's preferredContentSize from within my View Controller. The popover still fills up the screen though. I even tried the deprecated self.contentSizeForViewInPopover and that didn't work either. I tried in -awakeFromNib and -viewDidLoad.

What am I doing wrong?

- (void) awakeFromNib {
    [super awakeFromNib];

    self.preferredContentSize = CGSizeMake(500.0, 600.0);
    self.navigationController.preferredContentSize = self.preferredContentSize;

    self.contentSizeForViewInPopover = self.preferredContentSize;
    self.navigationController.contentSizeForViewInPopover = self.preferredContentSize;

}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.preferredContentSize = CGSizeMake(500.0, 600.0);
    self.navigationController.preferredContentSize = self.preferredContentSize;

    self.contentSizeForViewInPopover = self.preferredContentSize;
    self.navigationController.contentSizeForViewInPopover = self.preferredContentSize;
}
Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • Maybe this will help you (my [answer](http://stackoverflow.com/a/26507012/3151066) and others and the whole discussion) – Julian Oct 22 '14 at 12:04

1 Answers1

1

In iOS7 i just use a "fake" preferedContentSize to force a refresh of the popoverSize like that:

 CGSize currentSetSizeForPopover =  CGSizeMake(400, 130);
 CGSize fakeMomentarySize = CGSizeMake(currentSetSizeForPopover.width - 1.0f, currentSetSizeForPopover.height - 1.0f);
 self.preferredContentSize = fakeMomentarySize;
 self.preferredContentSize = currentSetSizeForPopover;

But in iOS8 it seems not working any more..

It work when i present it, but if i navigate to another viewController and then back to the root the preferredContentSize is not respected anymore..

Benetz
  • 447
  • 5
  • 18