UIImageWriteToSavedPhotosAlbum阻止主线程

时间:2011-12-19 17:51:47

标签: ios uiimage

我目前认识到

第一次函数调用
   UIImageWriteToSavedPhotosAlbum

阻止主线程约1 1/2秒,即使在iphone 4s / ipad2上也是如此。

我也尝试将它保存在一个单独的线程中:

-(void) storeInBackground
{
    NSAutoreleasePool *p = [NSAutoreleasePool new];
    UIImageWriteToSavedPhotosAlbum(imageView.image, nil,nil,nil);
    [p release];
}

 ....

 //call
 NSThread* thread1 = [[NSThread alloc] initWithTarget:self
                                                selector:@selector(storeInBackground)
                                                  object:nil];
 [thread1 setThreadPriority:0.1];
 [thread1 start];
 [thread1 release];

但是,一切都被封锁了。 在它曾经一直走向相册之后,它的速度很快。

有什么线索在这里做什么?

谢谢!

2 个答案:

答案 0 :(得分:2)

好的 - 拔掉电缆就行了!使用Xcode运行可以减慢速度,使用应用程序无需按预期快速调试它。

答案 1 :(得分:0)

尝试dispatch_async,你的减速可能会启动一个新的线程atm!祝你好运

dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
        UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, nil);
    });
相关问题