[英]App crashes when Back button tapped while scrolling table view
I present a modal table view within a navigation view with a Back button. 我在导航视图中使用“后退”按钮显示模态表视图。 The back button sends a message to the modal view's delegate to dismiss the modal view. 后退按钮向模态视图的委托发送消息以关闭模态视图。 If I scroll the table view and then tap the Back button on the navigation bar while the table view is still scrolling, the app crashes with this message: 如果我滚动表格视图,然后在表格视图仍在滚动时点击导航栏上的“返回”按钮,则应用程序会崩溃并显示以下消息:
*** -[UILayoutContainerView setUseFastMode:]: message sent to deallocated instance 0xef74650
When I PO 0xef74650 I get this: 当我PO 106ef74650我得到这个:
(int) $1 = 251086416 [no Objective-C description available]
Anyone experience this before? 以前有人经历过吗? What is the workaround or fix? 解决方法或修复方法是什么?
I believe this is a bug in iOS 5.1 that occurs when animating the dismissing of a modal that is currently scrolling. 我相信这是iOS 5.1中的一个错误,当动画解雇当前正在滚动的模态时发生。 I was getting reports from users that my app was crashing, and when I investigated I had the same error. 我收到用户的报告说我的应用程序崩溃了,当我调查时我遇到了同样的错误。
I created a new project with the minimal amount of code/views and was able to reproduce this crash. 我创建了一个具有最少量代码/视图的新项目,并且能够重现此崩溃。 The only workaround I've found so far is to disable animation when dismissing a modal. 到目前为止,我发现的唯一解决方法是在解除模态时禁用动画。 I've submitted a bug report to Apple. 我已经向Apple提交了一份错误报告。
I had a similar issue, my app was crashing if the table was still scrolling and I triggered a modal view to appear over the table. 我遇到了类似的问题,如果表格仍在滚动,我的应用程序崩溃了,我触发了一个模态视图显示在表格上方。 The crash in my instance was thrown in cellForRowAtIndexPath
, indexPath had been deallocated. 我的实例中的崩溃被抛入cellForRowAtIndexPath
,indexPath已被释放。
I fixed it by stopping scrolling in the viewWillDisappear
method:- 我通过在viewWillDisappear
方法中停止滚动来修复它: -
- (void) viewWillDisappear:(BOOL)animated {
[self.tableView setContentOffset:self.tableView.contentOffset animated:NO];
}
Hopefully this might help someone researching related problems! 希望这可能有助于研究相关问题的人!
iOS 5 has a bug in the FastModeAdditions category on UIView. iOS 5在UIView上的FastModeAdditions类别中有一个错误。 This bug manifests if you have a subview of the scroll view that is being scrolled in the same run loop as the modal view controller is being dismissed. 如果您在与模式视图控制器被关闭的同一个运行循环中滚动滚动视图的子视图,则会显示此错误。
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xa0000008
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x34bdef78 objc_msgSend + 16
1 UIKit 0x35309f9e -[UIView(FastModeAdditions) _setContainerLayoutViewForFastMode:] + 98
2 UIKit 0x351701cc -[UIView dealloc] + 568
3 UIKit 0x3545a39e -[UIDropShadowView dealloc] + 86
4 libobjc.A.dylib 0x34be016e _objc_rootRelease + 30
5 CoreFoundation 0x32b882e0 CFRelease + 88
The best work around we found is to performSelector:afterDelay: the dismissal. 我们找到的最好的工作是执行Selector:afterDelay:解雇。 This forces the dismissal on a later run loop and the crash no longer occurs. 这会强制解除后续运行循环并且不再发生崩溃。
This does not occur on iOS 6. 在iOS 6上不会发生这种情况。
检入setUseFastMode:
确保您没有发布以后尝试访问的内容。
[someObject release];
I was dismissing a modal when tapping a button inside the modal and getting this crash if its table was still scrolling. 当点击模态内部的按钮时,我正在解雇一个模态,如果它的表仍在滚动,则会导致崩溃。 This was incorrect: after moving the dismiss code to the presenting view controller, and calling it as part of a delegate method, the crash no longer occurs. 这是不正确的:在将解除代码移动到呈现视图控制器并将其作为委托方法的一部分调用之后,不再发生崩溃。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.