iOS Swift 2.0 UITextView freezes app depending on

2019-07-15 05:29发布

问题:

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.