【发布时间】:2016-01-24 12:53:02
【问题描述】:
我被难住了:-\
我在商店中有一个旧版应用程序,我正在为 iOS 8/9 刷新它。它是多年前(ARC 之前)编写的,是适用于 iPhone 和 iPad 的通用应用程序。除了这个之外,现在一切都在工作......
在 iPad 上,屏幕顶部有一个工具栏,我从中展示了包含 UINavigationController 的 UIPopoverControllers,其中包含一些您可以深入了解的标准 UITableViewController 类型的屏幕。
在纵向(和纵向倒置)中,一切都按预期工作。
然而,在横向模式中,按下“返回”(标准返回不是自定义的)会导致奇怪的动画 - 传出控制器跳出弹出框并快速滑出屏幕(方向由设备所在的方向决定),而只要传出控制器跳出弹出框,传入控制器就会立即出现。我不得不使用慢速动画来确定这一点,因为在全速下它看起来就像一个巨大的故障。
有一个简短的20 second movie showing the defect here;请注意在 14 秒后点击“位置”时会发生什么。
如果我将 VC 堆栈显示为表单而不是 UIPopover,则无论方向如何,一切都会按预期工作。我也尝试过更新的 UIPopoverPresentationController 并遇到了同样的问题,这让我有点惊讶。
这发生在我展示的两个弹出框上(一个从工具栏左侧,一个从工具栏右侧),它们都有非常不同的内部结构。唯一的共同点是它们在 UIPopover 中有一个 UINavigationController。
我已使用视图调试器检查视图层次结构,但似乎没有什么异常,而且无论我运行模拟器有多慢,我都无法在故障期间捕获视图,所以我怀疑我看到的是弹出框或导航控制器的内部问题。
有人见过类似的吗?我在设备上(iOS 8.4)和适用于 iOS 8 和 9 的模拟器中都看到了这一点。
就上下文而言,这个项目没有情节提要,很少使用 xibs,通常在 loadView 中用代码构建 UI - 它确实是一个旧应用程序...
感谢您的任何指点。不确定这里有多少代码会有所帮助,但这里是有关弹出框的演示;
LocationsViewController* locationsvc = [[LocationsViewController alloc] init];
UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:locationsvc];
localNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[locationsvc release];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:localNavigationController];
aPopover.delegate = self;
aPopover.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9];
self.locationPopoverController = aPopover;
[aPopover release];
[localNavigationController release];
[locationPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
我使用以下新风味代码遇到了同样的缺陷;
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:locationsvc];
locationsvc.preferredContentSize = CGSizeMake(320,280);
UIPopoverPresentationController *newPresentationController;
destNav.modalPresentationStyle = UIModalPresentationPopover;
newPresentationController = destNav.popoverPresentationController;
newPresentationController.barButtonItem = sender;
destNav.navigationBarHidden = NO;
[self presentViewController:destNav animated:YES completion:nil];
当我使用 UIModalPresentationPageSheet 时会出现同样的问题,但当我使用 UIModalPresentationFormSheet 时会出现同样的问题。
【问题讨论】:
-
感谢您随机投反对票:-/
-
所有 iOS 8.X 9.X 版本都会出现这种情况吗?可能是操作系统错误
-
当我深入研究 UITableViewController 代码时,我看到了类似的东西。我认为很明显,错误的发生是因为您要退回两个级别。向下钻取实际上将表格移到了左侧并看不见了。背面导致桌子从当前位置开始移动,因此出现了错误。我很犹豫要不要回答这个问题,但会做一些事情,比如从表中弹出向下钻取然后做弹出窗口。
标签: ios ipad uinavigationcontroller uipopovercontroller