3

So here's my problem.
I want to present a popover from a navigationbarbutton(works fine).
The contentviewcontroller of the popover is a UINavigationController with a UITableViewController as it's rootviewcontroller.
The presentation works fine.
Now i select a cell of the tableview, which leads another viewcontroller to be pushed onto the navigation-stack.
The viewcontroller will be pushed correctly, but now here appears a weird thing.
The popover will start getting resized(without animation) before the content is getting resized(with animation).

This is how i create my popover and present it:

UINavigationController* adsl_navctl = [[[UINavigationController alloc] initWithRootViewController:adsl_newnedit] autorelease];
self.adsc_current_popover = [[[dsd_popover_controller alloc] initWithContentViewController:adsl_navctl] autorelease];
_adsc_current_popover.delegate = self;
[adsl_newnedit.tableView layoutIfNeeded];
_adsc_current_popover.popoverContentSize = CGSizeMake(_adsc_current_popover.popoverContentSize.width, adsl_newnedit.tableView.contentSize.height + 38);
[_adsc_current_popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Here's how i resize my popover. self.contentSizeForViewInPopover isn't set anywhere else yet.
This is in all viewcontrollers, which are presented in the uinavigationcontroller. The size isn't the same everytime of course.

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    [UIView animateWithDuration:0.3 animations:^{
        [self forcePopoverSize];
    }];
}
}
- (void)forcePopoverSize {
    CGSize currentSetSizeForPopover = CGSizeMake(320, self.tableView.contentSize.height);
    CGSize fakeMomentarySize = CGSizeMake(currentSetSizeForPopover.width - 1.0f, currentSetSizeForPopover.height - 1.0f);
    self.contentSizeForViewInPopover = fakeMomentarySize;
    self.contentSizeForViewInPopover = currentSetSizeForPopover;
}

Some screenshots so you can understand my problem better(sorry new user, so cant post pics directly).
https://i.stack.imgur.com/copoA.png
https://i.stack.imgur.com/zJN1b.png
The content still is the size of the previous popover size even when the popover already resized. Normally it should resize both at the same time

Edit: After some time, i tried to look onto this again and i finally found a solution for me. In this Question the answer by "adnako" solved my problem.

Community
  • 1
  • 1
manuelwaldner
  • 551
  • 1
  • 5
  • 24

1 Answers1

0

For those who are interested in an alternative solution, I've made a demo application that shows how you can achieve correct and fluid resizing animations when working with navigation controllers inside of popovers. Check it out!

fatuhoku
  • 4,815
  • 3
  • 30
  • 70