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开发之微信山寨版),今天就开始给微信加上具体的实现功能,那么就先从微信的聊 ...
随机推荐
- instr函数
在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置. 语法如下:instr( string1, string2 [, start_position [, nth_appe ...
- 如何编译Less
什么是LESS LESSCSS是一种动态样式语言,属于CSS预处理语言的一种.它编译后就是CSS了,大名鼎鼎的前端框架BootStrap就是用这个语言写的 下面示范下怎么用LESS编译成CSS,尽量简 ...
- db2 进程
DB2 通用数据库进程全接触 Dwaine Snow, DB2 UDB 和 Informix IDS 产品经理, IBM 多伦多实验室 Dwaine Snow 是 DB2 UDB 分区数据库以及查询巡 ...
- operator
/* * 由SharpDevelop创建. * 用户: jinweijie * 日期: 2015/10/28 * 时间: 9:15 * * 要改变这种模板请点击 工具|选项|代码编写|编 ...
- 将asp.net页面弄成伪静态
在Web.config中写: <RewriterConfig> <Rules> <RewriterRule> <LookFor> ...
- 洛谷P1738 洛谷的文件夹
原题目:点我 题目是一个略水的题,我机制地用面向对象做了...所以代码量急剧加大,100行233 模拟即可,字符串处理麻烦点.如果没有找到子文件夹就新建文件夹,如果有就进入该文件夹. 提示:高能,指针 ...
- Centos7 Cacti-0.8.8g安装及SNMP简介
在官网可以看到关于cacti的下载说明http://www.cacti.net/download_cacti.php Download Cacti The latest stable version ...
- CardView的简单介绍
CardView是Android5.0中的一个全新控件,本质上而言,CardView是一个增加了圆角和阴影效果的FrameLayout,没错它就是一个FrameLayout,一个布局.CardView ...
- ZOJ3772_Calculate the Function
给出一些数组a[i],每次询问为li,ri,定义f[li]=a[li],f[li+1]=a[li+1],对于其他不超过ri的位置,f[x]=f[x-1]+a[x]*f[x-2] . 题目有着浓浓的矩阵 ...
- poj 2240 Arbitrage
Time Limit: 1000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u Java class name ...