实例化模态视图控制器会冻结应用程序 - Xcode 7的可能问题 [英] Instantiating Modal view controller freezes the app - Probable issue with Xcode 7

查看:87
本文介绍了实例化模态视图控制器会冻结应用程序 - Xcode 7的可能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用程序中以模态方式呈现视图控制器。问题是没有崩溃,应用程序会在调用presentViewController:animated时冻结。统计信息显示CPU使用率为100%,即使手动关闭应用程序后,使用率也不会下降。

I am presenting a view controller modally in iOS app. The issue is that there is no crash and the app freezes as soon as presentViewController:animated is called. The stats show the CPU usage to be 100% and the usage doesn't go down even after manually closing the app.

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CustomModalViewController *vvc = [sb instantiateViewControllerWithIdentifier:@"CustomModalViewController"];
if(!vvc){
    NSLog(@"ERROR!!! vvc is null");
}
NSLog(@"instantiate modal view controller");

vvc.providesPresentationContextTransitionStyle = YES;
vvc.definesPresentationContext = YES;
vvc.data = data;
NSLog(@"before presenting modal view controller");
[vvc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
[self presentViewController:vvc animated:YES completion:nil];

我尝试在我的自定义类的viewDidLoad中打印一些调试语句,但这些也没有被调用。

I tried printing some debug statements in the viewDidLoad of my custom class, but those are also not getting called.

我不明白为什么没有显示视图控制器。任何帮助将不胜感激。我想知道你的应用程序在推送视图控制器时进入无限循环的情况是什么?或者是因为其他原因?

I don't understand why the view controller is not being displayed. Any help will be appreciated. I want to know in what case does your app go into infinite loop on pushing a view controller or is it because of some other cause??

更新:

我更新到XCode 7后发生此错误。不确定,但我想这可能是新SDK-UIKit或LLVM编译器的问题。我用Xcode 6.4将我的项目复制到另一个mac,错误消失了!我没有更改任何会导致问题的构建设置。

This error occured after I updated to XCode 7. Not sure, but I guess this might be an issue with new SDK- the UIKit or LLVM compiler. I copied my project to another mac with Xcode 6.4 and the error disappears!!! I haven't changed any build settings either that would cause the issue.

关于如何进行的任何指示?

Any pointers on how to proceed?

推荐答案

好的,这很奇怪,但我希望它有所帮助:我有完全相同的问题,CPU跳到100%和视图永远不会显示。在Xcode 6.4中运行良好。在Xcode 7.1中,在我调用的视图中,我有一个带有一些占位符文本注释:的UITextView。我发现如果我清除占位符文本,视图LOADS和所有过程都正常执行。如果占位符文本长度大于9个字符,则视图也会加载并且过程正常执行。如果占位符文本长度> 0且< 10,这是不行的。没有视图和CPU 100%。我意识到这很奇怪,但希望它会帮助你。和你一样,我没有显示任何错误或控制台输出,它只是旋转。

Ok, this is bizarre, but I hope it helps: I have the EXACT same issue, the CPU jumps to 100% and view never shows. Works perfectly well in Xcode 6.4. In Xcode 7.1, on the view that I am calling, I have got a UITextView with some placeholder text "Notes:". What I found is that if I clear out the placeholder text, the view LOADS and all of the procedures execute as normal. If the placeholder text length is greater than 9 characters, the view also loads and procedures execute as normal. If the placeholder text length >0 and < 10, it's a no go. No view and CPU at 100%. This is odd, I realize, but hopefully it helps you out. Like you, I've got no errors or console output to show, it just spins.

编辑仅供参考,删掉占位符文本故事板,只是在代码中设置它也可以修复它,无论长度如何

EDIT FYI, blanking out the placeholder text in the storyboard, and just setting it in code fixes this as well irrespective of length

这篇关于实例化模态视图控制器会冻结应用程序 - Xcode 7的可能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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