pmc*_*255 5 iphone exc-bad-access objective-c uitextview
我试图UITextView在基本视图中使用简单,但它会导致应用程序偶尔崩溃.有时它在我输入内容时崩溃,有时当我滚动时,有时在我按下返回键后.从堆栈跟踪看,它看起来像是由图形或动画相关代码引起的,用于渲染用于拼写检查,语法检查等的UI元素.
为什么这会让我的应用程序崩溃?我是否需要导入其他库,还是需要为UITextView指定某种委托?我确实只是在准系统视图中有一个简单的UITextView,没什么特别的.
这是堆栈跟踪:
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x9535f9b1 in ?? ()
#1 0x9534c33f in ?? ()
#2 0x9534c13e in ?? ()
#3 0x9634df5c in ?? ()
#4 0x9418d244 in CGDataProviderRetain ()
#5 0x963b7036 in ?? ()
#6 0x98263486 in CGImageReadCreateWithProvider ()
#7 0x982633a2 in CGImageSourceCreateWithDataProvider ()
#8 0x020c0947 in CGImageCreateWithPNGDataProvider ()
#9 0x02ebfeed in WKGraphicsCreateImageFromBundleWithName ()
#10 0x02ebfc3b in WebCore::GraphicsContext::drawLineForMisspellingOrBadGrammar ()
#11 0x02ebf9cb in WebCore::InlineTextBox::paintSpellingOrGrammarMarker ()
#12 0x02e73932 in WebCore::InlineTextBox::paintDocumentMarkers ()
#13 0x02e730a1 in WebCore::InlineTextBox::paint ()
#14 0x02e717ef in WebCore::InlineFlowBox::paint ()
#15 0x02e71565 in WebCore::RootInlineBox::paint ()
#16 0x02e71220 in WebCore::RenderLineBoxList::paint ()
#17 0x0354c451 in WebCore::RenderBlock::paintContents ()
#18 0x02e6d7bd in WebCore::RenderBlock::paintObject ()
#19 0x02e6ed51 in WebCore::RenderBlock::paint ()
#20 0x02e6dcf2 in WebCore::RenderBlock::paintChildren ()
#21 0x02e6d7bd in WebCore::RenderBlock::paintObject ()
#22 0x02e6ed51 in WebCore::RenderBlock::paint ()
#23 0x02e6c502 in WebCore::RenderLayer::paintLayer ()
#24 0x02e6bce3 in WebCore::RenderLayer::paintLayer ()
#25 0x02e6b635 in WebCore::RenderLayer::paint ()
#26 0x02e6b3de in WebCore::FrameView::paintContents ()
#27 0x03bd71da in -[WebFrame(WebInternal) _drawRect:contentsOnly:] ()
#28 0x03bd7104 in -[WebHTMLView drawSingleRect:] ()
#29 0x02e6af68 in _WKViewDraw ()
#30 0x02e6b03f in _WKViewDraw ()
#31 0x02e6b03f in _WKViewDraw ()
#32 0x02e6b03f in _WKViewDraw ()
#33 0x02e6b03f in _WKViewDraw ()
#34 0x02e6adb0 in WKViewDisplayRect ()
#35 0x02e6ad41 in WKWindowDrawRect ()
#36 0x02e6a9d3 in WebCore::TileCache::drawLayer ()
#37 0x04041d63 in backing_callback ()
#38 0x0404161e in CABackingStoreUpdate ()
#39 0x040407f4 in -[CALayer _display] ()
#40 0x02e6a3d4 in -[TileLayer display] ()
#41 0x040402b1 in CALayerDisplayIfNeeded ()
#42 0x0403f65b in CA::Context::commit_transaction ()
#43 0x0403f2b0 in CA::Transaction::commit ()
#44 0x04046f5b in CA::Transaction::observer_callback ()
#45 0x02391d1b in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#46 0x02326987 in __CFRunLoopDoObservers ()
#47 0x022efc17 in __CFRunLoopRun ()
#48 0x022ef280 in CFRunLoopRunSpecific ()
#49 0x022ef1a1 in CFRunLoopRunInMode ()
#50 0x02c152c8 in GSEventRunModal ()
#51 0x02c1538d in GSEventRun ()
#52 0x002e2b58 in UIApplicationMain ()
Run Code Online (Sandbox Code Playgroud)
编辑:似乎这确实是由自动更正功能引起的,正如堆栈跟踪所暗示的那样.如果我将Interface Builder中的"文本输入特征"下的"更正"属性(我相信它是UITextInputTraits协议的autocorrectionType属性)设置为"否",那么问题就会消失.使用自动更正,我总是可以通过键入拼写错误的单词来重现错误.
另外需要注意的是,这是我昨天刚刚下载的最新iOS 4.1 SDK,所以我不知道这是否是最新SDK中的UITextView错误或者是什么.
编辑2:哇,我真的很难过.我从头开始创建了一些新项目,并试图用UITextViews显示模态视图控制器,它们都没有问题.但是,当我尝试在我的实际应用程序中执行相同操作时 - 无论我尝试从哪个控制器调用模态视图控制器 - 它总是崩溃.我把代码煮到了准系统,但它仍然崩溃了.这是我初始化模态视图控制器的方法:
- (IBAction)showFeedback:(id)sender {
FooViewController *controller = [[FooViewController alloc] initWithNibName:@"FooView" bundle:nil];
[self presentModalViewController:controller animated:YES];
[controller release];
}
Run Code Online (Sandbox Code Playgroud)
FooViewController只是一个由Xcode生成的骨架视图控制器,它继承自UIViewController.什么都没有被覆盖.我的nib文件只包含一个带有单个香草UITextView的空视图.其他一切都是默认的.
在输入拼写错误的单词后,崩溃总是立即发生,模拟器会尝试显示红色下划线.
我也尝试过运行NSZombieEnabled,我在日志中看不到有关发送给僵尸的消息.
我的应用程序非常简单 - 基于标签的应用程序,我的每个标签都有导航控制器.然后将我的5个自定义视图控制器设置为每个导航控制器的根控制器.我目前有一个自定义视图控制器创建并呈现模态控制器.我已尝试在父视图控制器中注释掉任何释放调用,但无济于事.
我不明白的是,哪些对象是试图访问的图形例程,可能已被释放(或未保留)属于我的应用程序在内存管理方面的责任?在我看来,唯一可能的是UITextView,我尝试将其声明为具有retain的属性,并将其设置为Interface Builder的插座.不过,同样的崩溃.
任何帮助是极大的赞赏!!!
EXC_BAD_ACCESS 基本上意味着您正在访问应用程序未使用的内存。我的猜测是您正在编辑变量或访问已发布的变量。评论你的版本,看看进展如何。
编辑:也可能意味着您没有保留需要的变量。
| 归档时间: |
|
| 查看次数: |
2915 次 |
| 最近记录: |