所以这是我的问题。
我想从导航栏按钮显示一个弹出窗口(工作正常)。
popover 的 contentviewcontroller 是一个带有 UITableViewController 的 UINavigationController,因为它是 rootviewcontroller。
演示效果很好。
现在我选择 tableview 的一个单元格,这导致另一个 viewcontroller 被推送到导航堆栈上。
viewcontroller 会被正确推送,但是现在这里出现了一个奇怪的东西。
在内容调整大小(有动画)之前,弹出框将开始调整大小(无动画)。
这就是我创建弹出窗口并呈现它的方式:
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];
这是我调整弹出窗口大小的方法。 self.contentSizeForViewInPopover 尚未在其他任何地方设置。
这是在 uinavigationcontroller 中呈现的所有 View Controller 中。当然每次大小都不一样。
- (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;
}
一些截图可以让你更好地理解我的问题(对不起新用户,所以不能直接发布图片)。
http://i.stack.imgur.com/copoA.png
http://i.stack.imgur.com/zJN1b.png
即使弹出窗口已经调整大小,内容仍然是之前弹出窗口大小的大小。通常它应该同时调整两者的大小
编辑:过了一段时间,我试着再次研究这个问题,我终于找到了适合我的解决方案。 在这个Question “adnako”的回答解决了我的问题。
最佳答案
对于那些对替代解决方案感兴趣的人,我制作了一个 demo application that shows how you can achieve correct and fluid resizing animations when working with navigation controllers inside of popovers .检查一下!
关于ios - UIPopoverController 以不同的速度调整 popover 和 content-viewcontroller(uinavigationcontroller) 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18714154/