Objective c iOS6 UIViewControllerHierarchyOn按钮单击时的一致性
我在iOS 6 iPad中面临问题Objective c iOS6 UIViewControllerHierarchyOn按钮单击时的一致性,objective-c,ipad,ios-simulator,ios6,Objective C,Ipad,Ios Simulator,Ios6,我在iOS 6 iPad中面临问题 在按钮上单击->打开带有UITable的弹出窗口 在“选择行->modalviewcontroller打开” 关闭modalviewcontroller(工作正常) 然后再次点击按钮,点击按钮时应用程序崩溃(第一步) 此问题仅在iOS 6中出现。它在iOS 5和iOS 4.3中运行良好 *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency',
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View <UITableView: 0xb847400; frame = (0 0; 185 104); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0xa469e50>; layer = <CALayer: 0xa469f00>; contentOffset: {0, 0}> is associated with <UIViewController: 0xa462f60>. Clear this association before associating this view with <UIViewController: 0xa5dac40>.'
*** First throw call stack:
(0x2769012 0x1d0be7e 0x2768deb 0xca1309 0xd385ac 0xd34a90 0x69b19 0x1d1f705 0xc56920 0xc568b8 0xd17671 0xd17bcf 0xd16d38 0xc8633f 0xc86552 0xc643aa 0xc55cf8 0x29a2df9 0x29a2ad0 0x26debf5 0x26de962 0x270fbb6 0x270ef44 0x270ee1b 0x29a17e3 0x29a1668 0xc5365c 0x24ca 0x23d5)
libc++abi.dylib: terminate called throwing an exception
更仔细地查看您的异常:
'UIViewControllerHierarchyInconsistency', reason:
'A view can only be associated with at most one view controller at a time!
View UITableView: 0xb847400; frame = (0 0; 185 104); clipsToBounds = YES;
autoresize = W+H; gestureRecognizers = NSArray: 0xa469e50; layer = CALayer: 0xa469f00;
contentOffset: {0, 0} is associated with UIViewController: 0xa462f60.
Clear this association before associating this view with UIViewController: 0xa5dac40.'
具体而言:
A view can only be associated with at most one view controller at a time!
View UITableView: 0xb847400
is associated with
UIViewController: 0xa462f60.
Clear this association before associating this view with
UIViewController: 0xa5dac40.
这意味着您有一个视图控制器,它的。view
属性被设置为您的listTable对象。然后,在不破坏该关联的情况下,使用另一个视图控制器并尝试将其.view
属性设置为listTable对象。这违反了视图层次结构规则,从iOS 6.0开始,苹果对该规则的执行力度更大,以至于它现在抛出异常并使你的应用程序崩溃
因此,这里真正的问题是,您将同一个listTable对象与两个视图控制器一起使用,特别是popoverContent
。这意味着当代码第二次执行时,旧的popoverContent仍然存在,这就是为什么它在第二次运行时崩溃,而不是第一次运行时崩溃。我猜你的代码在新的popover被创建之前没有完全释放和销毁旧的popover;如果你能确保这一切发生,你可能会没事的
我还注意到,显然,您对这两个弹出窗口使用相同的列表表。您是否希望为每个popover懒洋洋地创建此列表表,而不是保留它
如果您想进一步调查,可以在代码中设置断点,并使用po
命令打印不同视图和视图控制器的描述,以查看哪些十六进制地址与随后将出现在异常中的地址相匹配,并获取有关问题的更多信息。或者,您甚至可以直接使用十六进制地址打印描述:po 0xa469e50
(不过可能需要对其进行打字)
除此之外,您还没有提供足够的代码供其他人查看并说出问题所在:),但以上内容应该可以帮助您解决问题。更仔细地查看您的异常:
'UIViewControllerHierarchyInconsistency', reason:
'A view can only be associated with at most one view controller at a time!
View UITableView: 0xb847400; frame = (0 0; 185 104); clipsToBounds = YES;
autoresize = W+H; gestureRecognizers = NSArray: 0xa469e50; layer = CALayer: 0xa469f00;
contentOffset: {0, 0} is associated with UIViewController: 0xa462f60.
Clear this association before associating this view with UIViewController: 0xa5dac40.'
具体而言:
A view can only be associated with at most one view controller at a time!
View UITableView: 0xb847400
is associated with
UIViewController: 0xa462f60.
Clear this association before associating this view with
UIViewController: 0xa5dac40.
这意味着您有一个视图控制器,它的。view
属性被设置为您的listTable对象。然后,在不破坏该关联的情况下,使用另一个视图控制器并尝试将其.view
属性设置为listTable对象。这违反了视图层次结构规则,从iOS 6.0开始,苹果对该规则的执行力度更大,以至于它现在抛出异常并使你的应用程序崩溃
因此,这里真正的问题是,您将同一个listTable对象与两个视图控制器一起使用,特别是popoverContent
。这意味着当代码第二次执行时,旧的popoverContent仍然存在,这就是为什么它在第二次运行时崩溃,而不是第一次运行时崩溃。我猜你的代码在新的popover被创建之前没有完全释放和销毁旧的popover;如果你能确保这一切发生,你可能会没事的
我还注意到,显然,您对这两个弹出窗口使用相同的列表表。您是否希望为每个popover懒洋洋地创建此列表表,而不是保留它
如果您想进一步调查,可以在代码中设置断点,并使用po
命令打印不同视图和视图控制器的描述,以查看哪些十六进制地址与随后将出现在异常中的地址相匹配,并获取有关问题的更多信息。或者,您甚至可以直接使用十六进制地址打印描述:po 0xa469e50
(不过可能需要对其进行打字)
除此之外,您还没有提供足够的代码供其他人查看并说出问题所在:),但以上内容应该可以帮助您解决问题。您可以将
列表表作为子视图添加,而不是替换popoverContent
的视图吗
不确定这是否能完全满足您的要求,但它可能会避免层次结构不一致性错误。您能否将列表表作为子视图添加,而不是替换popoverContent
的视图
不确定这是否能完全满足您的要求,但它可能会避免层次结构不一致错误。最有可能的情况是您正在发布popover,这是一个需要解决的简单问题。您可以显示调用和取消popover的代码吗?我的代码在第行崩溃PopoOverContent.view=listTable代码>最有可能的情况是您正在发布popover,这是一个需要解决的简单问题。您可以显示调用和取消popover的代码吗?我的代码在第PopoOverContent.view=listTable行崩溃代码>好的,它面向细节的答案,也检查一下这个。那么,它的答案是以细节为导向的,也请检查这一个。