iOS Swift 2.0 UITextView 根据文本冻结应用程序 [英] iOS Swift 2.0 UITextView freezes app depending on text

查看:28
本文介绍了iOS Swift 2.0 UITextView 根据文本冻结应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Swift 2.0 应用遇到了一个奇怪的问题.

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

我在我的故事板中定义了一个(可编辑的)UITextView.如果我将故事板中的 text 属性留空,一切都会按预期工作.但是,当我输入文本 Kaasje(在情节提要中并重新编译)时,应用程序在加载笔尖(通过 segue 导航)时冻结并且 CPU 跳到 100%(应用程序仍然卡住).应用程序此时永远不会到达 viewDidLoad.

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.

在 Xcode 中暂停并没有给我留下任何有用的东西,主线程很忙,没有指定任何函数.没有记录到输出,也没有创建任何日志.

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.

我在 iPad Air 上运行 iOS9,该应用有一个内置的 iOS8 目标并且只能横向运行.

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.

附言其他文本也会发生这种情况,但Kaasje"总是失败.当文本只有 1 行时,它似乎失败了.较长的文本往往会成功,同时也将其留空.

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.

推荐答案

正如评论中所建议的,似乎有一个 Xcode 7 与 iOS9 结合的错误.

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.

这篇关于iOS Swift 2.0 UITextView 根据文本冻结应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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