简体   繁体   English

iOS 9 Segue导致应用程序冻结(没有崩溃或错误抛出)

[英]iOS 9 Segue Causes App To Freeze (no crash or error thrown)

I have been working on this app for months now and from as far back as I can remember I have never had an issue with segues. 我已经在这个应用程序上工作了好几个月,从我记忆中来看,我从来没有遇到过segue的问题。 The code is unchanged in terms of calling performSegueWithIdentifier but since my recent update to Xcode 7 and iOS 9 I have not been able to tack this issue. 代码在调用performSegueWithIdentifier方面没有变化,但是由于我最近对Xcode 7和iOS 9的更新,我无法解决这个问题。

I have tried: 我试过了:

  • Deleting button and creating new button w/ segue link 删除按钮并创建带有segue链接的新按钮
  • Using a direct segue from button to view, without the use of performSegueWithIdentifier 使用直接segue从按钮查看,而不使用performSegueWithIdentifier
  • Connecting button to new blank viewController 连接按钮到新的空白viewController

When I press the button, no initial load functions are called on the destination VC (Ex: ViewDidLoad , ViewWillAppear , etc). 当我按下按钮时,目标VC上没有调用初始加载函数(例如: ViewDidLoadViewWillAppear等)。 When I connect it to a blank view, the segue works fine with the same code in place. 当我将它连接到空白视图时,segue可以正常使用相同的代码。

Since the code never stops, or breaks, and just seems to "freeze" in place while still running on Xcode I can't seem to even narrow this down to whats causing the issue. 由于代码永远不会停止或中断,并且只是在仍然在Xcode上运行时似乎“冻结”,我似乎无法将其缩小到导致问题的原因。 I have a similar segue that is also called from another button on the same ViewController that has no issues whatsoever. 我有一个类似的segue,也可以从同一个ViewController上的另一个按钮调用,它没有任何问题。

Any thoughts on the matter are greatly appreciated! 对此事的任何想法都非常感谢!

EDIT: I have narrowed the issue down to the UITextView 's causing the problem. 编辑:我已将问题缩小到UITextView导致问题。 Once the Text Views were removed the page loads fine via segue. 一旦删除了文本视图,页面就会通过segue加载。 I wonder what changed between iOS 8 and iOS 9 in terms of UITextView as I will have to remove the text views and completely re add new text views. 我想知道iOS 8和iOS 9在UITextView方面有什么变化,因为我将不得不删除文本视图并完全重新添加新的文本视图。

So basically the segue was freezing because of the UITextView 's I was using in the destinationViewController . 所以基本上segue是冻结的,因为我在destinationViewController中使用了UITextView The following fixed the issue: 以下修复了该问题:

  • Delete all UITextView 's 删除所有UITextView
  • Add new UITextView's 添加新的UITextView
    • you must leave the default lorem imposed text and change this programmatically in the viewDidLoad() 你必须保留默认的lorem强制文本并在viewDidLoad()中以编程方式更改

This was the fix for me, and from the research I have done on the issue it seems this is a bug in iOS 9 and Xcode 7. 这是我的修复,从我在这个问题上所做的研究来看,这似乎是iOS 9和Xcode 7中的一个错误。

Cheers! 干杯!


NOTE: Removing the text in the UITextView (or making it longer then ~12 characters) is sufficient to work around it, no need to delete and recreate them. 注意:删除UITextView中的文本(或使其长度超过12个字符)足以解决它,无需删除和重新创建它们。 This is fixed in Xcode 7.1.1 and later. 这在Xcode 7.1.1及更高版本中得到修复。

I ran into the same issue and the fixes in this post ( Xcode 7 crash: [NSLocalizableString length] 30000 ) solved the issue for me. 我遇到了同样的问题,这篇文章中的修复( Xcode 7崩溃:[NSLocalizableString length] 30000 )为我解决了这个问题。

The first is to enable a localisation other than the base for the storyboard (see https://stackoverflow.com/a/32688815/3718974 ) 第一种是为故事板启用除基础之外的本地化(请参阅https://stackoverflow.com/a/32688815/3718974

The second is to turn off the base localisation (see https://stackoverflow.com/a/32719247/3718974 ) 第二是关闭基础本地化(参见https://stackoverflow.com/a/32719247/3718974

I think I have the same problem: I have a UITabelView with cells created from a nib file, when a user tap a cell this method is called: 我想我有同样的问题:我有一个UITabelView,其中包含从nib文件创建的单元格,当用户点击一个单元格时调用此方法:

在此输入图像描述

and when I have the following method prepareForSegue:: the application crashes: 当我有以下方法prepareForSegue ::应用程序崩溃: 在此输入图像描述

if I delete the line 129 Everything is ok , the method prepareForSegue:: open the right view and the label contactName is shown with its default text. 如果我删除行129一切正常,方法prepareForSegue ::打开右视图,标签contactName以其默认文本显示。 If I modify the method as follows prepareForSegue:: get exactly what you expect, without having any type of error: 如果我修改方法如下,prepareForSegue :: get正是你所期望的,没有任何类型的错误:

在此输入图像描述

let me know if you also get the same result 如果你也得到相同的结果,请告诉我

Any one who is facing this issue, i solved it by turning off the "Optimize rendering for windows scale" option in Debug of simulator window. 任何人都面临这个问题,我通过关闭模拟器窗口调试中的“优化窗口缩放渲染”选项解决了这个问题。 I already had tried all of the above answers but could not solve the issue. 我已经尝试过所有上述答案,但无法解决问题。

In the method in the first viewController where you activate the segue, do you have beginIgnoringInteractionEvents anywhere? 在你激活segue的第一个viewController中的方法中,你在任何地方都有beginIgnoringInteractionEvents吗? If so the screen you segue to will be frozen and will ignore interaction events like you describe. 如果是这样,您所选择的屏幕将被冻结,并将忽略您描述的交互事件。 If this is the case you can fix this by adding an endIgnoringInteractionEvents method before your segue method: 如果是这种情况,您可以通过在segue方法之前添加endIgnoringInteractionEvents方法来解决此问题:

UIApplication.sharedApplication().endIgnoringInteractionEvents() self.performSegueWithIdentifier("editItemToMyGearSegue", sender: self) UIApplication.sharedApplication()。endIgnoringInteractionEvents()self.performSegueWithIdentifier(“editItemToMyGearSegue”,sender:self)

I realize this is an old topic, but appears to be still relevant. 我意识到这是一个古老的话题,但似乎仍然具有相关性。 I was facing the same problem in Xcode 9, iOS11. 我在Xcode 9,iOS11中遇到了同样的问题。 My UITextViews are embedded inside UITableViewCells. 我的UITextViews嵌入在UITableViewCells中。 Same symptoms as described here. 与此处描述的症状相同。 The tricks with default text and placeholders did nothing for me, but I solved it by turning off the scrolling indicators for the text view in the xib. 默认文本和占位符的技巧对我没有任何作用,但我通过关闭xib中文本视图的滚动指示符来解决它。 They were on by default, I guess, though unused. 我猜,它们默认处于启用状态,但未使用。

Edit: this is probably an important detail... the views that were hanging all had an image NSTextAttachment in the attributed string of the text view. 编辑:这可能是一个重要的细节...挂起的视图都在文本视图的属性字符串中有一个图像NSTextAttachment。 I think the image was wider than the available table cell content. 我认为图像比可用的表格单元格内容更宽。 With scrolling turned off, they appear to downscale. 滚动关闭后,它们会显示缩小范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM