2011-10-05 61 views
0

編輯:用「方法Swizzle崩潰」作爲前綴,以幫助其他人找到該錯誤。方法Swizzle崩潰:越南語鍵盤失敗並崩潰

對於在越南鍵盤上的模擬器或運行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:時,接收到的字符串是有效的。

一切似乎表明,這是一個蘋果問題,但我沒有發現任何其他在線問題的報告。我的直覺說這是我的代碼中的東西。任何人都可以借給你一個提示嗎?

+0

我剛剛爲此獲得了風滾草徽章。任何人都可以加入挑戰嗎? – AWrightIV

+0

上述信息(以及當時可用的信息)不足以找到解決方案。事實證明,這是一個更廣泛的問題。它影響了3.0操作系統上的鍵盤以及越獄設備上的應用程序。有關決議的信息將在正式答覆中提供。 – AWrightIV

回答

0

此答案中的信息對於使用方法調整時遇到類似問題的人來說最爲有用。有關方法調整的解釋,請參閱here

我swizzled pathForRes:ofType:在NSBundle爲我自己的方法,搜索我的應用程序已加載的每個包。它還搜索我的應用程序隨附的資源檔案。現在的問題是:鍵盤通常從iOS內部專用的捆綁包中訪問數據。我的混搭方法無法訪問這些,所以鍵盤會間歇性地失敗,並且不會告訴我爲什麼。

爲了解決這個問題,我修改了swizzled方法,這樣如果我的應用程序的方法找不到資源,它會調用[NSBundle pathForResource:ofType:]的原始實現。

問題解決。