调用alloc init时,UIImagePickerController确实很慢 [英] UIImagePickerController really slow when calling alloc init

查看:896
本文介绍了调用alloc init时,UIImagePickerController确实很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图控制器,按下tabBarController中的一个选项卡。在此视图控制器中,我在viewDidLoad方法中初始化UIImagePickerController:

I have a view controller that is presented on pressing on one of the tabs in a tabBarController. In this view controller I initialise a UIImagePickerController in the viewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Set imagePicker
    //-------------------------//
    _imagePicker = [[UIImagePickerController alloc] init];
    _imagePicker.delegate = self;
    _imagePicker.videoMaximumDuration = 10.0f;
}

目的是在稍后按钮显示时显示UIImagePickerController按下。出于某种原因,虽然为此视图控制器按下选项卡图标时,此viewDidLoad方法正在运行时有3-4秒的挂起。当我注释掉行_imagePicker = [[UIImagePickerController alloc] init]时,没有挂起时间,视图控制器立即加载 - 应该如此。

The intention is to then display the UIImagePickerController at a later time when a button is pressed. For some reason though when the tab icon is pressed for this view controller, there is a 3-4 second hang while this viewDidLoad method is running. When I comment out the line _imagePicker = [[UIImagePickerController alloc] init] there is no hang time and the view controller loads immediately - as it should.

有谁知道为什么分配和初始化UIImagePickerController需要这么长时间?如果是这样,除了将其作为后台进程运行之外,有没有办法加快速度?这似乎不是正常行为。

Does anyone know why allocating and initialising the UIImagePickerController is taking so long? If so, is there a way to speed it up other than running it as a background process? It seems like this is not normal behaviour.

我使用的是iOS7,我没有调用viewWillAppear或viewDidAppear。

I am using iOS7, and I am not calling viewWillAppear or viewDidAppear.

推荐答案

原来这只是在调试模式下(当iPhone连接并通过Xcode运行时)的一个问题。一旦相同的应用程序在没有连接到Xcode的情况下运行,就不会出现延迟。

Turns out this is only a problem when in debug mode (when the iPhone is connected and running through Xcode). Once the same app is running without being connected to Xcode the lag doesn't occur.

这篇关于调用alloc init时,UIImagePickerController确实很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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