iOS,ARC:后台线程冻结UI

Pau*_*tin 2 user-interface xcode uiimagepickercontroller ios automatic-ref-counting

我有一个UIViewController,UITableView作为子视图.单击某个单元格时,应显示UIImagePickerController.由于它需要很长的初始化时间,因此当UIViewController出现时,我在后台执行此过程.
现在我将ARC添加到我的项目中,然后它仍然无法正常工作.用户界面被初始流程冻结了.

这是我的代码.

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self performSelectorInBackground:@selector(initImagePickerControllerInBackground) withObject:nil];
}

...

- (void)initImagePickerController
{
    if (imagePickerController != nil)
        return;

    imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.allowsEditing = YES;
    imagePickerController.delegate = self;
    imagePickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
}

- (void)initImagePickerControllerInBackground
{
    @autoreleasepool
    {
        [self initImagePickerController];
    }
}
Run Code Online (Sandbox Code Playgroud)

为了让它适合我,我应该改变什么?

isa*_*aac 5

UIKit不是线程安全类,不应该从主线程外部调用.您不应该在后台执行此UIImagePickerController分配/交互.