iOS SDK中的UIScrollView EXC_BAD_ACCESS崩溃 [英] UIScrollView EXC_BAD_ACCESS crash in iOS SDK

查看:129
本文介绍了iOS SDK中的UIScrollView EXC_BAD_ACCESS崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPhone SDK应用程序,有多个视图在用户创建内容时出现和消失。在设备上使用该应用程序一段时间后,我遇到以下崩溃:

I have an iPhone SDK application that has several views that appear and disappear as the user creates content. After using the application on a device for a while, I get the following crash:

Program received signal:  "EXC_BAD_ACCESS".
(gdb) backtrace
#0  0x33369ebc in objc_msgSend ()
#1  0x320e5248 in -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded] ()
#2  0x338b4a14 in -[NSObject performSelector:withObject:] ()
#3  0x320e5098 in -[UIAnimator stopAnimation:] ()
#4  0x320e4b7c in -[UIAnimator(Static) _advance:] ()
#5  0x320e4a34 in LCDHeartbeatCallback ()
#6  0x34350e60 in HeartbeatVBLCallback ()
#7  0x332e91c0 in IOMobileFramebufferNotifyFunc ()
#8  0x316532f8 in ?? ()
#9  0x33866b50 in __CFMachPortPerform ()
#10 0x338ae52a in CFRunLoopRunSpecific ()
#11 0x338adc1e in CFRunLoopRunInMode ()
#12 0x3434e1c8 in GSEventRunModal ()
#13 0x32002c30 in -[UIApplication _run] ()
#14 0x32001230 in UIApplicationMain ()
#15 0x00002ff8 in main (argc=1, argv=0x2ffff550) at /Developer/svn/MyCompany/iPhone/MyApplication/Other Sources/main.m:14

从追踪中可以看出,唯一提到我的代码中有对main的调用。

As you can see from the trace, the only mention of my code in there is the call to main.

我已经从Xcode运行Build and Analyze,并且还设置它来运行我项目中的clang分析器终端,这两个都在代码中找不到任何问题。我正在使用最近发布的iOS SDK版本(我还没有下载4.1版本,但我使用的版本是4.1之前发布的版本)。

I have run Build and Analyze from Xcode, and also set it up to run the clang analyzer on my project from the Terminal, and both of these cannot find any problems in the code. I am using a very recent release version of the iOS SDK (I have not downloaded the 4.1 yet, but the one I am using is the one that was in release right before 4.1).

另外,我已经使用模拟器在Instruments中运行应用程序,并且应用程序没有内存泄漏。

Also, I have run the application in Instruments with the Simulator, and the app has no memory leaks.

我即将尝试使用 NSZombieEnabled 变量并查看是否找到了任何内容,但问题是我需要在崩溃前使用该应用程序30到40分钟左右,我怀疑 NSZombieEnabled 甚至可能无法帮助我找到问题。

I am about to try to use the NSZombieEnabled variable and see if that finds anything, but the problem is that I need to use the application for 30 to 40 minutes or so before it crashes, and I suspect that NSZombieEnabled may not even help me find the issue.

我看到的崩溃似乎是模态视图调用时的崩溃委托在父视图控制器中。然后父视图控制器在解除模态视图控制器之前进行一些处理。崩溃中有一些参考动画和滚动视图,但我不知道我可以做些什么导致那些有问题。有没有人有任何建议可以寻找?

It seems like the crashes that I have seen is when a modal view calls a delegate in the parent view controller. The parent view controller then does some processing before dismissing the modal view controller. There is some references in the crash to animating and scroll views, but I am not sure what I could be doing to cause those to have problems. Does anyone have any suggestions for things to look for?

编辑:我已经把 NSZombieEnabled 标记进入应用程序,并在设备上,它在控制台中显示此消息:

I have put the NSZombieEnabled flag into the application, and on the device, it comes up with this message in the console:

2010-09-11 17:10:33.970 MyApplication[9321:207] *** 
-[MyViewController respondsToSelector:]: message 
sent to deallocated instance 0x7489480

据我所知,我将应用程序中使用的委托设置为所有类的deallocs中的nil,所以我被困在哪里看下一步。

As far as I can tell, I am setting the delegates used in the application to nil in the deallocs of all my classes, so I am stuck as to where to look next.

我试图在此使用 malloc_history pid地址命令,但它说它不能找到这个过程,我尝试了9321,9321:207和207.另外,如果我尝试使用 MallocStackLogging 变量,程序将无法在设备上运行,我得到一堆 malloc:无法在控制台和程序cr中创建堆栈日志目录消息ash。

I tried to use the malloc_history pid address command on this, but it said that it could not find the process, I tried 9321, 9321:207, and 207. Also, if I try to use the MallocStackLogging variable, the program will not run on the device, I get a bunch of malloc: unable to create stack log directory messages in the console and a program crash.

哦,顺便说一下,我不能使用仪器中的僵尸检查,因为它似乎不适用于设备,我可以'在模拟器中发生相同的崩溃。

Oh, and by the way, I can't use the zombies checking in Instruments, since it does not appear to work with a device, and I can't get the same crash to happen in the Simulator.

推荐答案

UIScrollView 在堆栈帧#1上可能想要通知其委托有关动画结束的信息,但代表在那时就消失了。设置 NSZombieEnabled 可能会确认这一点。

The UIScrollView on stack frame #1 probably wants to inform its delegate about the animation ending, but the delegate is gone at that point. Setting NSZombieEnabled would probably confirm this.

不保留代理,因此这是Cocoa和Cocoa中的常见错误触摸。在您的代码中查找 UIScrollView UITableView 上的代理,并尝试找出可能在其时间之前发布的代理。

Delegates are not retained, so this is a common error in Cocoa and Cocoa Touch. Look for delegates on UIScrollView or UITableView in your code and try to find out which one might be released before its time.

这篇关于iOS SDK中的UIScrollView EXC_BAD_ACCESS崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆