iOS Swift 2.0 UITextView freezes app depending on text

不想你离开。 提交于 2019-12-14 01:56:57

问题


I'm experiencing a weird issue with my Swift 2.0 app.

I have a (editable) UITextView defined in my storyboard. If I leave the text property empty in the storyboard everything is working as expected. But when I enter the text Kaasje (in the storyboard and recompiling), the app freezes when loading the nib (navigating through segue) and the CPU jumps to 100% (the app remains stuck). The app will never reach viewDidLoad at this point.

It makes no difference when changing between fonts or fontsizes, behavior remains.

Pausing in Xcode does not leave me with anything useful, the main thread is busy without specifying any function. Nothing is logged to output nor any logs are created.

I'm running iOS9 on a iPad Air, the app has a built target of iOS8 and runs landscape-only.

Has anyone ever experienced anything like this before, and might have an explanation for this behaviour?

As far as my assumptions: Something goes wrong when calculating the text-size which results in a infinite loop while either calculating the size or adjusting the frame.

P.S. It happens with other texts too, but "Kaasje" always fails. It seems to fail when the the text is only 1 line. Longer texts tend to succeed aswel as leaving it empty.


回答1:


As suggested in the comments there seems to be a bug in Xcode 7 in combination with iOS9.

I ended up recreating the entire view, the problem did not occur again.



来源:https://stackoverflow.com/questions/32699509/ios-swift-2-0-uitextview-freezes-app-depending-on-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!