Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

objective c - UITextView with text less than 10 characters hangs iOS 9

Starting from iOS 9 (I used Xcode 7.0 beta 6 (7A192o)), an Objective-C app with UITextView will hang if the text view's text is less than 10 characters. CPU usage goes up to 99-100% and the whole system hangs.

How to reproduce:

  1. Create a brand new single view app from template (or anything else).
  2. In storyboard, add a UITextView with default settings anywhere in the main view.
  3. Set the text to a string that is less than 10 characters long.
  4. Launch the app in simulator (any device, as long as it's iOS 9).
  5. Upon launch, before displaying the single view, the system will hang and CPU usage will go to maximum forever.
  6. Set the text to any other text that's more than 10 characters and the app runs correctly.a

Looks like constraints or any other settings do not affect this behaviour.

The immediate solution would be to simply not have less than 10 characters, but, well, that's lame.

You can check out this github repository that also demonstrates the problem.

I also submitted a bug report to Apple (bug no. 22736256, although you probably can't see it there yet).

Weirdest. Bug. Ever.

Is anyone also encountering this one??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Took me half a day to narrow the error down to a UITextView. This has got to be the stupidest bug ever.

You don't need to ensure that the UITextView holds at least 10 characters. Just adding a default of at least 10 characters to the UITextView in Interface Builder will fix the problem. Then, you can empty the UITextView using code.

By the way, this is an Xcode 7 bug, not an iOS9 bug. New builds built using Xcode 7 will create the same problem in iOS7 and iOS8.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...