编辑:用“Method Swizzle Crash”为问题添加前缀,以帮助其他人找到错误。
对于在模拟器或任何运行 iOS 4 或更高版本的设备上的越南语键盘上按下的每个键,控制台都会打印以下消息,并且不会向第一响应者发送任何字符:
Can't find transliterator file: vi_TelexTransliterator
utrans_transUChars error U_ILLEGAL_ARGUMENT_ERROR
我的服务器或客户端代码中没有这些字符串或子字符串的实例。这来自 API。
运行 iOS 4 的模拟器和设备将在第二次按键时持续崩溃。iOS 5 上没有崩溃。调用堆栈顶部的错误如下所示:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString substringToIndex:]: Range or index out of bounds'
调用堆栈如下所示:
Foundation -[NSString substringToIndex:]
TextInput -[TIKeyboardInputManagerZephyr internalIndexToExternal:]
TextInput -[TIKeyboardInputManagerZephyr inputCount]
UIKit -[UIKeyboardImpl addInputString:fromVariantKey:]
UIKit -[UIKeyboardImpl handleStringInput:fromVariantKey:]
UIKit -[UIKeyboardImpl handleKeyEvent:]
UIKit -[UIApplication _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIResponder(Internal) _handleKeyEvent:]
UIKit -[UIApplication handleKeyEvent:]
UIKit -[UIKeyboardLayoutStar sendStringAction:forKey:]
UIKit -[UIKeyboardLayoutStar touchUp:]
UIKit -[UIKeyboardLayout touchesEnded:withEvent:]
UIKit -[UIWindow _sendTouchesForEvent:]
UIKit -[UIWindow sendEvent:]
UIKit -[UIApplication sendEvent:]
UIKit _UIApplicationHandleEvent
GraphicsServices PurpleEventCallback
CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
CoreFoundation __CFRunLoopDoSource1
CoreFoundation __CFRunLoopRun
CoreFoundation CFRunLoopRunSpecific
CoreFoundation CFRunLoopRunInMode
GraphicsServices GSEventRunModal
GraphicsServices GSEventRun
UIKit -[UIApplication _run]
UIKit UIApplicationMain
APP main (main.m:XXX)
我已经在整个应用程序的多个位置尝试过这个键盘,包括在加载主视图之前的安全屏幕上,并且我们所有的输入处理方法都在它的委托中注释掉了。失败是一致的。当实现委托方法并且我逐步执行 textField:shouldChangeCharactersInRange:replacementString: 时,收到的字符串是有效的。
一切似乎都表明这是一个 Apple 问题,但我没有在网上找到有关该问题的其他报告。我的直觉说这是我的代码中的东西。任何人都可以提供提示吗?