Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用addChildViewController添加ViewController导致性能降低(100%CPU)_Ios_Performance_Uiviewcontroller_Subview - Fatal编程技术网

Ios 使用addChildViewController添加ViewController导致性能降低(100%CPU)

Ios 使用addChildViewController添加ViewController导致性能降低(100%CPU),ios,performance,uiviewcontroller,subview,Ios,Performance,Uiviewcontroller,Subview,这里需要你的帮助。 我将添加ViewController作为另一个ViewController的子视图 addedVC = self.storyboard!.instantiateViewControllerWithIdentifier("text_layout") as! TextLayoutCollectionView self.view.addChildViewController(addedVC) addedVC.view.frame = self.view.bounds addedVC

这里需要你的帮助。 我将添加ViewController作为另一个ViewController的子视图

addedVC = self.storyboard!.instantiateViewControllerWithIdentifier("text_layout") as! TextLayoutCollectionView
self.view.addChildViewController(addedVC)
addedVC.view.frame = self.view.bounds
addedVC.view.frame.origin = CGPointMake(0, 0)
self.view.addSubview(addedVC.view)        
addedVC.didMoveToParentViewController(toVC)
我用同样的方法添加了4个ViewController作为子视图

iPhone4上运行iOS7的速度非常慢,大约3-4秒后就可以完成所有操作。加上CPU增加到100%。 在运行iOS8的iPhone6+上,似乎可以像预期的那样工作。 我可能认为
实例化eviewcontrollerwhidentifier
会导致速度变慢。
有什么建议吗?

看看哪个线程正在使用CPU。暂停调试器中的应用程序,看看该线程在做什么。嘿,rmaddy,@rmaddy,我如何在不设置断点的情况下停止调试器?iPhone4有一个单核CPU。您的孩子VCs是否正在将工作转为异步线程?在该设备上,他们正在减慢主线程。单击调试器中的“暂停”图标。@Graham嘿,Graham,嗯,我不确定我是否完全理解你的意思。但是VC(所有)只持有CollectionView,我没有从他们那里运行任何其他东西。看看哪个线程正在使用CPU。暂停调试器中的应用程序,看看该线程在做什么。嘿,rmaddy,@rmaddy,我如何在不设置断点的情况下停止调试器?iPhone4有一个单核CPU。您的孩子VCs是否正在将工作转为异步线程?在该设备上,他们正在减慢主线程。单击调试器中的“暂停”图标。@Graham嘿,Graham,嗯,我不确定我是否完全理解你的意思。但是VC(所有人)只持有CollectionView,我没有从他们那里运行任何其他东西。