ios - iOS 7 UITextView在输入大量文本后很慢 [英] ios - iOS 7 UITextView is slow after typing lots of text

查看:245
本文介绍了ios - iOS 7 UITextView在输入大量文本后很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了在输入大量文本时在iOS 7上的UITextView中发生的减速问题。我在NSLayoutManager中放置了一个跟踪器,并确定drawGlyphsForGlyphRange运行N * 2次,其中N是你的行换行的次数。

I'm having trouble with a slowdown that occurs in UITextView on iOS 7 when typing lots of text. I put a tracer in NSLayoutManager and identified that drawGlyphsForGlyphRange runs N*2 times, where N is the number of times your lines word-wrapped.

以下是示例代码:

https://github.com/philipkd/UITextViewSlow

要重现问题,请在iPad上运行并附加物理键盘。将字母和空格键混合约15秒,然后注意它减慢速度。然后当你尝试正常打字时,它真的很慢。这是一个极端的例子,但是如果你只是尝试以合理的速度键入两个段落,它就会卡住。

To reproduce the problem run it on an iPad and attach a physical keyboard. Mash the letters and the space bar for about 15 seconds, and notice it slows down. Then when you try to type normally, it's really slow. That's an extreme example, but if you just try typing two paragraphs at a reasonable speed, it'll jam up.

这对iOS 6上的UITextView来说不是问题。

This is not a problem with UITextView on iOS 6.

推荐答案

设置常规中关闭后台应用刷新。另外,摆脱NSLog - 它们的速度超出了打印速度。

Turn off Background App Refresh in Settings General. Also, get rid of NSLog--they slow down beyond what it takes them to print.

我能够在IOS7下重现iPad上的减速效果。实际上IOS6没有后台应用程序刷新

I was able to reproduce the slow down effect on iPad under IOS7. In fact IOS6 did not have Background App Refresh.

我相信Apple的目标是顶级模型,所有其他人都必须调整。

I believe Apple aims for top of the line models, all others have to adjust.

这篇关于ios - iOS 7 UITextView在输入大量文本后很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆