码迷,mamicode.com
首页 > 移动开发 > 详细

textViewDidChange: crashes in iOS 7

时间:2015-09-18 18:11:42      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

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.

textViewDidChange: crashes in iOS 7

标签:

原文地址:http://www.cnblogs.com/ygm900/p/4819784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!