iOS 4.3模拟器中UITextField自动更正崩溃

24

UITextField的自动更正在使用iOS 4.3 sdk构建目标的模拟器上导致我的应用程序崩溃。在使用iOS 4.2 sdk的设备和模拟器中可以正常工作。

还有其他人遇到这个问题吗?我想这可能是4.3 sdk的一个错误?

只要我输入第二个字符,就会立即出现堆栈跟踪。

#0  0x01c01000 in objc_assign_ivar ()
#1  0x03b7ec34 in -[AppleSpell init] ()
#2  0x007e7538 in -[UITextChecker _checker] ()
#3  0x007e8de9 in -[UITextChecker checkSpellingOfString:startingAt:language:wrap:correction:] ()
#4  0x0b335725 in TIInputManagerZephyr::lookup_spellcheck_candidates(KB::String const&) ()
#5  0x0b3353f3 in TIInputManagerZephyr::lookup_static_dynamic_candidates(KB::String const&, KB::String const&, KB::Vector<KB::FPoint> const&, bool) ()
#6  0x0b332b2b in TIInputManager::lookup() ()
#7  0x0b332e18 in TIInputManager::autocorrection() ()
#8  0x0b34a06b in -[TIKeyboardInputManagerZephyr autocorrection] ()
#9  0x005cfbe8 in -[UIKeyboardImpl generateCandidatesWithCompletions:] ()
#10 0x005cfc3b in -[UIKeyboardImpl generateCandidates] ()
#11 0x005dca23 in -[UIKeyboardImpl addInputString:fromVariantKey:] ()
#12 0x005de71b in -[UIKeyboardImpl handleKeyEvent:] ()
#13 0x0070a2ee in -[UIKeyboardLayoutStar sendStringAction:forKey:] ()
#14 0x0070ed19 in -[UIKeyboardLayoutStar touchUp:] ()
#15 0x005ebda2 in -[UIKeyboardLayout touchesEnded:withEvent:] ()
#16 0x004b8ded in -[UIWindow _sendTouchesForEvent:] ()
#17 0x00499c37 in -[UIApplication sendEvent:] ()
#18 0x0049ef2e in _UIApplicationHandleEvent ()
#19 0x02011992 in PurpleEventCallback ()
#20 0x0176a944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#21 0x016cacf7 in __CFRunLoopDoSource1 ()
#22 0x016c7f83 in __CFRunLoopRun ()
#23 0x016c7840 in CFRunLoopRunSpecific ()
#24 0x016c7761 in CFRunLoopRunInMode ()
#25 0x020101c4 in GSEventRunModal ()
#26 0x02010289 in GSEventRun ()
#27 0x004a2c93 in UIApplicationMain ()

有时候,你会看到一个简单得多的跟踪,它只是从主函数开始,然后立即在 objc_assign_ivar 处停止。当在文本字段(例如 UISearchBar)中输入时也会发生这种情况。


是的,我也以为我一个人遇到了这个问题。对于那些使用 Lion 系统的人,请通过官方渠道提交报告;这样比通过标准的错误报告网站获得更多关注。 - FeifanZ
6个回答

34

在模拟器上,打开“设置”→“键盘”,将所有选项关闭。 这样可以防止崩溃(直到修复此漏洞)。


谢谢,已经在 Lion GM + Xcode 4.2 Preview 4 上解决了这个问题。模拟器正在运行 iOS 4.3。 - Imran Raheem
仍然在 Lion 10.7.2 + Xcode 4.2 GM 中出现问题,模拟器运行 iOS 4.3,但在模拟器 iOS5 上正常工作。 - bentford

7

我遇到了同样的问题,在Lion Developer Preview 2上运行4.3模拟器。这是模拟器在Lion上的一个bug。我暂时禁用了自动更正(setAutocorrectionType: UITextAutocorrectionTypeNo)。


这个可行,最近看起来行之有效的是@CraicDesign的解决方案。 - Schoob
在这里遇到同样的问题,使用 Lion GM + Xcode 4.2 Preview 3。模拟器正在运行iOS 4.3。禁用UITextView上的自动更正可以防止崩溃发生。 - Joseph Lin
顺便说一下,在我的Snow Leopard机器上完全相同的代码运行没有任何崩溃(Xcode 4.2预览版3 + 4.3模拟器)。 - Joseph Lin

6

我们需要按照以下步骤更新模拟器4.3:

  1. 进入Xcode -> 首选项 -> 下载
  2. 更新iOS 4.3模拟器

然后重置模拟器并再次运行即可完成。


3

1
在模拟器键盘设置中关闭“自动更正”功能,可以解决我的问题。

enter image description here


0

我也遇到了这个问题。在我的情况下,我能够追踪到它是由于一个当前具有焦点的文本字段的resignFirstResponder调用引起的。

我有类似以下代码:

if(loginSuccess) {
    [self.userName resignFirstResponder]; 
    [self.password resignFirstResponder]; // This is the one with focus
}

现在当我注释掉密码 resignFirstResponder 调用时,就不再出现崩溃了。

这绝对是一个 bug,应该报告。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接