iOS 系统crash探寻之路

来源:互联网 发布:不亦说乎 不亦悦乎 编辑:程序博客网 时间:2024/05/22 07:08


解决方案: 直接网上查到资料

http://stackoverflow.com/questions/19948394/textviewdidchange-crashes-in-ios-7

What's happening is that you're typing what is referred to as multistage text input, i.e. the input has to be confirmed from the user before it's actually committed into the underlying text. You get the crash because the text is only kind-of inputted, and until the text has been committed, it could easily change to something else.

To detect this situation, you're looking for the markedTextRange property of the UITextView, which indicates if you're in this complex input mode.

If the property is non-nil, then you're in this special input mode, so you should guard your modification code with something like:

if (self.tv.markedTextRange == nil && self.tv.text.length > maxLength) {    // Perform change}

Near as I can tell the crash is triggered by the special multistage text input mode, so you should avoid changing the text while this mode is active.

复杂输入法模式时做一下以上的保护就可以了
0 0
原创粉丝点击