ios - UIPopoverController 以不同的速度调整 popover 和 content-viewcontroller(uinavigationcontroller) 的大小

标签 ios objective-c uinavigationcontroller resize uipopovercontroller

所以这是我的问题。
我想从导航栏按钮显示一个弹出窗口(工作正常)。
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”的回答解决了我的问题。

最佳答案

关于ios - UIPopoverController 以不同的速度调整 popover 和 content-viewcontroller(uinavigationcontroller) 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18714154/

相关文章:

ios - 无法将导航栏添加到场景 : Root view controller issue?

ios - 带有 Google Cardboard 的 Unity 5.6 在每只眼睛中显示非常不同的图像

ios - 运行 Stanford 的 CS193p Smashtag 应用程序时出现 _BSMachError

ios - Xcode本地化文件复制不正确

ios - 在 iOS 中声明条件委托(delegate)方法

iphone - iOS 多任务手势 - 禁用/启用

objective-c - NSWindow 注册鼠标事件(使用 NSTrackingArea),即使应用程序未获得焦点?

ios - 当我们放置两个 640 x 960 和 640 x 1136 尺寸的飞溅时,不需要自动布局

swift - 仅当 View Controller 通过滑动或后退按钮按下而不是通过切换选项卡从堆栈中弹出时才发送数据

ios - 导航栏的注销按钮 navigationController 问题