UIImagePickerController really slow when calling alloc init

穿精又带淫゛_ 提交于 2019-12-01 04:39:33

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.

Try this

//show a HUD or activityIndicator
dispatch_async(dispatch_queue_create("openPhotosCamera", NULL), ^{

    UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];

    dispatch_async(dispatch_get_main_queue(), ^{
        //hide HUD or activityIndicator
        [presenter presentViewController:mediaUI animated:YES completion:nil];
    });
});

**presenter is yourViewController / self

Try this.

    - (void)viewDidLoad{

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

[super viewDidLoad];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!