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.

时间: 2024-07-31 08:44:21

textViewDidChange: crashes in iOS 7的相关文章

iOS textView在调用textViewDidChange方法,九宫格相关中文输入的问题

问题一 iOS textView在调用 UITextViewDelegate 的 textViewDidChange方法,九宫格相关中文输入的问题 有时候,需要在textViewDidChange处理相关逻辑判断时,在中文输入的情况下,例如输入"中",对应的拼音"zhong", 在textViewDidChange的方法里会把拼音也算进去:这就导致输入中文时也输入不需要的英文. 还有例如在九宫格下输入@字符 textViewDidChange方法会调用两次:这就导致

IOS 键盘的显示与关闭,以及移动显示(UITextView处理完整版)

IOS 键盘的显示与关闭 在每一个IOS应用中,几乎不可避免的要进行文本输入操作,例如要求用户填写登陆注册信息,进行话题的评论回复,等等.用到的文本输入组件有UITextField,UITextView,对于这两个组件的相关属性和方法想必大家都很熟悉,但貌似对于键盘的显示或隐藏过程貌似常常不是很清楚,其实本人也是一知半解,所以趁此做简单的总结,基本上以下描述出自于官方的文档,并没有什么更改. 1.开启键盘面板 当用户触击某一个view时,系统会自动指定该view为第一响应对象(first res

IOS总结(学习过程中整理的笔记)

MVC模式:(model+view+controller):是一种帮你把代码功能和显示划分出来的设计模式: model:较为底层的数据引擎,负责管理实体中所继承的数据: view:和用户交互界面: controller:连接二者的桥梁: cocoa frameworks 有两个框架: foundation foundation  是cocoa中最基本的一些类:再mac应用程序中负责对象管理,内存管理,容器等相关数据: uikit: uikit:为程序提供可视化的底层构架,包括窗口,视图,控件类和

IOS开发基础知识--碎片22

1:设置有间距的表格行(UITableViewStyleGrouped) 1.设置section的数目,即是你有多少个cell - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; // in your case, there are 3 cells} 2.对于每个section返回一个cell - (NSInteger)tableView:(UITableView *)tableView nu

Overview of iOS Crash Reporting Tools: Part 1/2

Believe it or not, developers are not perfect, and every once in a while you might have a (gasp!) bug in your app. You will try your best to ship your apps with no bugs in them, but more often than not you realise afterwards that a bug has slipped th

Overview of iOS Crash Reporting Tools: Part 2/2

Thanks for joining me for the second part of this two-part series on crash reporting services! The first part introduced you to the architecture of crash reporting services, including storage, symbolication, and server-side management. As well, I pro

经典好文:android和iOS平台的崩溃捕获和收集

通过崩溃捕获和收集,可以收集到已发布应用(游戏)的异常,以便开发人员发现和修改bug,对于提高软件质量有着极大的帮助.本文介绍了iOS和android平台下崩溃捕获和收集的原理及步骤,不过如果是个人开发应用或者没有特殊限制的话,就不用往下看了,直接把友盟sdk(一个统计分析sdk)加入到工程中就万事大吉了,其中的错误日志功能完全能够满足需求,而且不需要额外准备接收服务器. 但是如果你对其原理更感兴趣,或者像我一样必须要兼容公司现有的bug收集系统,那么下面的东西就值得一看了. 要实现崩溃捕获和收

Unity3D Optimizing Graphics Performance for iOS

原地址:http://blog.sina.com.cn/s/blog_72b936d801013ptr.html icense Comparisons http://unity3d.com/unity/licenses#iphone Optimizing Graphics Performance http://unity3d.com/support/documentation/Manual/Optimizing Graphics Performance.html iOS A useful bac

iOS OpenGLES 框架相关 24 篇文档排序整理

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. OpenGLES Use a compact, efficient subset of the OpenGL API for 2D and 3D