0

編集:他の人がバグを見つけるのを助けるために、質問の前に「MethodSwizzleCrash」を付けました。

シミュレーターまたはiOS4以降を実行しているデバイスのベトナム語キーボードで押されたキーごとに、次のメッセージがコンソールに出力され、最初のレスポンダーに文字が送信されません。

Can't find transliterator file: vi_TelexTransliterator
utrans_transUChars error U_ILLEGAL_ARGUMENT_ERROR

サーバーまたはクライアントコードにこれらの文字列またはサブ文字列のインスタンスはありません。これはAPIから来ています。

iOS 4を実行しているシミュレーターとデバイスは、2回目のキーを押すと常にクラッシュします。iOS5ではクラッシュは発生しません。コールスタックの最上位のエラーは次のようになります。

*** 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の問題であることを示しているようですが、私はこの問題に関する他の報告をオンラインで見つけていません。私の腸はそれが私のコードの何かだと言っています。誰かがヒントを貸すことができますか?

4

1 に答える 1

0

この回答の情報は、メソッドスウィズリングを使用するときに同様の問題が発生している場合に最も役立ちます。スウィズリングメソッドの説明については、こちらをご覧ください。

NSBundleのpathForResource:ofType:をスウィズルして、アプリケーションがロードしたすべてのバンドルを検索する独自のメソッドを探しました。また、アプリに同梱されているリソースアーカイブも検索します。ここで問題があります。キーボードは通常、iOS内部専用のバンドルからのデータにアクセスします。私のswizzledメソッドはそれらにアクセスできなかったので、キーボードが断続的に失敗し、その理由についての有用な情報が得られませんでした。

これを解決するために、アプリのメソッドでリソースが見つからなかった場合に[NSBundle pathForResource:ofType:]の元の実装を呼び出すように、swizzledメソッドを変更しました。

問題が解決しました。

于 2011-10-28T02:27:34.063 に答える