【问题标题】:ABPersonViewController causes UIViewControllerHierarchyInconsistency on iPad when choosing a photoABPersonViewController 在选择照片时导致 iPad 上的 UIViewControllerHierarchyInconsistency
【发布时间】:2012-12-04 15:16:32
【问题描述】:

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

** 由于未捕获的异常“UIViewControllerHierarchyInconsistency”而终止应用程序,原因:“一个视图一次最多只能与一个视图控制器关联!看法 ; }; layer = > 与 <_uiactionsheethostingcontroller:> 相关联。在将此视图与 <_uiactionsheethostingcontroller:> 关联之前清除此关联。'*

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

【问题讨论】:

  • 我也有同样的问题。尝试通过推送到导航控制器并以模态方式在新导航控制器中显示来呈现 ABUnknownPersonViewController,但两种解决方案都存在同样的问题。
  • 我现在使用弹出框来编辑联系人,效果很好。
  • 当我把它放在弹出窗口中时,我在启用文本字段时没有键盘

标签: iphone ios ipad


【解决方案1】:

这似乎是 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多