gpt4 book ai didi

iphone - ABPersonViewController 在选择照片时导致 iPad 上的 UIViewControllerHierarchyInconsistency

转载 作者:行者123 更新时间:2023-12-01 16:53:37 25 4
gpt4 key购买 nike

我在 UINavigationController 中使用 ABPersonViewController 来显示和编辑联系信息。到目前为止,这一直使用最新的 xcode 版本(当前为 4.5.2)和 iOS6。如果用户选择 ABPersonViewController 上的编辑按钮, View 将进入编辑模式(如预期的那样),但现在如果他们选择照片(添加或更改现有照片)然后“选择照片”应用程序崩溃并出现以下异常?.. .

** 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“一个 View 一次最多只能与一个 View Controller 相关联!看法 ; }; layer = > 与 <_UIActionSheetHostingController: 0x4da1190> 相关联。在将此 View 与 <_UIActionSheetHostingController: 0x5f38830> 关联之前清除此关联。 *

它似乎是针对 iPad 的——我想这与 iPad 如何将操作表视为弹出框有关,除非它显示在弹出框内。任何帮助将不胜感激。

最佳答案

这似乎是 UIViewController 的新定向方法的问题:

- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

似乎选择照片 VC 没有实现它们,因此请确保您的根 VC 确实实现了它们,即使它的顶级 VC 没有。

在代码中:
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate {
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations {
UIInterfaceOrientationMask topControllerOrientationMask = [self.topViewController supportedInterfaceOrientations];
return topControllerOrientationMask ? topControllerOrientationMask : UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
UIInterfaceOrientation topControllerOrientation = [self.topViewController preferredInterfaceOrientationForPresentation];
return topControllerOrientation ? topControllerOrientation : UIInterfaceOrientationPortrait;
}
@end

关于iphone - ABPersonViewController 在选择照片时导致 iPad 上的 UIViewControllerHierarchyInconsistency,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13706042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com