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开发之微信山寨版),今天就开始给微信加上具体的实现功能,那么就先从微信的聊 ...
随机推荐
- mysql 字符串处理优化
周五下午,同事突然说有个存储过程要帮忙优化,就拿来看看,大概看了下: 数据库端需求:数据库中要存储一个AppID字段,对应一个Account可以自行设置自己的AppID(我就不从业务上多说了), 以前 ...
- [Python] 关于64位机的numpy安装问题
最近刚换成64位的系统,重新安装了win10,VS也从原来的2010变为了现在的2013. 利用原来32位电脑硬盘里的python2.7安装包安装,然后打算安装numpy. 上来碰到问题:在windo ...
- c++中级 STL基础学习(二)
deque 和vector差不多,可以在前端后端插入,一般用deque取代vector,vector只能在后端插入push_back().deque还可以push_front(),但是deque后端插 ...
- Storm启动流程简介
storm启动流程 storm是一个流行的开源的,分布式实时处理框架,关于storm的基本介绍可以参加这篇官方文档.大致的拓扑结构如图所示: 其中Nimbus是一个后台 ...
- UVALive 3942 Remember the Word(字典树+DP)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- NY 269 VF
题目 求1—1000000000之间的数,它的各位数字之和为 s. dp[i][j]表示 i 位数,它的各位数之和为 j 的总个数. 这里假设第 i 位为 k,则前 i - 1 位的和应为 j - k ...
- git clone 错误ca-certificates.crt
git clone https://github.com/baoyiluo/selfblog.git Cloning into 'selfblog'... error: server certific ...
- 第十八章:Android 打包部署
Andriod应用程序如果要在手机或模拟器上安装,必须要有签名! 1.签名的意义 为了保证每个应用程序开发商合法ID,防止部分开放商可能通过使用相同的Package Name来混淆替换已经安装的程序, ...
- why add \n to http response.responseText
这是今天我们公司线上出现的问题,http response 的信息,都添加了一个\n换行,我找了好久呢 才发现,我把php页面的结束符?>去掉之后,一切正常,这个?>,我平时也是很少加上的 ...
- Android布局中涉及的一些属性
Android:gravity属性 线性布局常见的就是利用LinearLayout进行布局,其中有个比较重要的属性就是android:gravity,在官方文档中是这么描述这个属性的:指定一个元素怎么 ...