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.
textViewDidChange: crashes in iOS 7的更多相关文章
- iOS开发笔记12:iOS7上UITextField限制字数输入导致崩溃问题
在一些场景中,需要限制用户的输入字数,例如在textField里进行控制(textView也类似,崩溃原因也相同),如图所示 系统会监听文本输入,需要注意的第一点是输入法处于联想输入还未确定提交的时候 ...
- 移动平台unity3d优化
目录(?)[-] Focus on GPUs 着眼于GPU Good practice 优秀的实践 Sharer optimizations 着色器优化 Focus on CPUs 着眼于CPUs G ...
- iOS - UITextView在调用textViewDidChange方法,九宫格相关中文输入的问题
问题一 iOS textView在调用 UITextViewDelegate 的 textViewDidChange方法,九宫格相关中文输入的问题 有时候,需要在textViewDidChange处理 ...
- iOS 报错:(子线程中更新UI)This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
今天在写程序的时候,使用Xcode 运行工程时报出下面的错误错信息,我还以为是什么呢,好久没遇到过这样的错误了. **ProjectName[1512:778965] This application ...
- iOS textView在调用textViewDidChange方法,中文输入的问题
有时候,需要在textViewDidChange处理时,在中文输入的情况下,例如输入“中”,对应的拼音“zhong”, 在textViewDidChange的方法里会把拼音也算进去:导致输入中文时也输 ...
- iOS开发之Alamofire源码解析前奏--NSURLSession全家桶
今天博客的主题不是Alamofire, 而是iOS网络编程中经常使用的NSURLSession.如果你想看权威的NSURLSession的东西,那么就得去苹果官方的开发中心去看了,虽然是英文的,但是结 ...
- iOS编码规范
The official raywenderlich.com Objective-C style guide. This style guide outlines the coding con ...
- IOS错误Could not produce class with ID
运行环境 Unity 5.3.5f1 (IL2CPP)编译IOS版本 XCode Version 7.2.1 (7C1002) Mac OS X 10.11.3 (15D21) (Mac mini) ...
- iOS开发之微信聊天工具栏的封装
之前山寨了一个新浪微博(iOS开发之山寨版新浪微博小结),这几天就山寨个微信吧.之前已经把微信的视图结构简单的拖了一下(IOS开发之微信山寨版),今天就开始给微信加上具体的实现功能,那么就先从微信的聊 ...
随机推荐
- ghost 还原系统时,遇到error 10010,提示can not open image file
昨天系统有点问题,在用Ghost还原系统时,一直提示10010错误,提示can not open image file 想着可能是备份文件的问题,从另一台电脑上重新拷过来一份,仍然不行,Ghost还是 ...
- sqlserver中,查看某个函数的调用情况
今天想在sqlserver中看看自己写的函数都被哪个函数或存储过程调用了,手工检查起来太慢了,于是在网上找一个快速的方法,分享一下. select * from sys.all_sql_modules ...
- php变量判断为空的几种方法
1.isset 主要用来判断变量是否被初始化过 注意:当使用isset来判断数组元素是否被初始化过时,它的效率比array_key_exists高4倍左右 2.empty 可以将值为 " ...
- uglifyjs压缩JS的
一.故事总有其背景 年末将至,很多闲适的时间,于是刷刷微博,接触各种纷杂的信息——美其名曰“学习”.运气不错,遇到了一个新名词,uglifyjs. 据说是用来压缩JS文件的,据说还能优化JS,据说是基 ...
- c++实战吐槽(我还是太年轻了)
习惯了用java, 现在切换到c++遇到了一些很滑稽的问题, 特此记录. 一. 使用了野指针 都知道不能使用野指针, 指针定义后,要初始化为null, 我在项目里面默认构造函数里面确实初始化为null ...
- css之字体设置
字体大小font-size 字体风格font-style 字体加粗font-weight 字体类型font-family 字体阴影text-shadow 字体行高line-height 字间距lett ...
- Myeclipse加载maven
1.自带,需要将之前下好的文本加入到myeclipse中即可.windows---->preference---->Myeclipse---->MavenMyeclipse 3.将本 ...
- JavaScript 高性能笔记
浏览器解析 JavaScript .CSS .DOM 时,一般都是单线程解析,所以,引用外部文件时的位置不同,UE体验也不同. 下面是 Yahoo 大牛 Nicholas C. Zakas 的 < ...
- dispaly 的block与inline-block的用法
一直以来没有弄清block与line-block的用法,今天花点时间整理一下. <body> <div class="div1">div1</div& ...
- Install Solr+tomcat
1. chose the release you want: http://archive.apache.org/dist/lucene/solr/. 1) copy [solr_home]/dist ...