After I select a photo with the camera I m saving it as NSData
. This takes a while and I dont want my users to wait for it. I want it to happen at the background. My question is whether it is wise to perform methods after I call "dismissModalViewControllerAnimated:NO
".
这是我的法典,其产出如下:
debug1
debug2
debug4
debug5
debug6
debug3
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSLog(@"debug1");
// Save image in the normal photo album
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
NSLog(@"debug2");
[[MySingleton sharedSingleton] addImg:image];
NSLog(@"debug3");
[picker dismissModalViewControllerAnimated:NO];
[_delegate startStep2];
}
-(void) addImg: (UIImage *) img {
NSLog(@"debug4");
NSData *jpegData = UIImageJPEGRepresentation([img rotateAndScaleFromCameraWithMaxSize:1500.0], 0.9f);
NSLog(@"debug5");
image = [[NSData alloc] initWithData:jpegData];
NSLog(@"debug6");
}
Can 我首先要 dismiss弃观点控制者,而不是其他 st子,或者说这种好的方式?
edit//我确实通过这样做解决了等待问题:
[[MySingleton sharedSingleton] performSelectorInBackground:@selector(addImg:) withObject:image];