【发布时间】:2012-01-14 14:50:59
【问题描述】:
我有一个 UITableViewController,它弹出一个 UIImagePickerController,用户拍照,点击使用按钮,在处理图像时,Picker 关闭以显示自定义缩略图微调器,然后微调器在最后被实际缩略图替换处理。
至少它在 iOS4 中是这样工作的。现在使用 iOS5,它只是坐在那里处理直到完成,然后一切正常。但我想要那个微调器,以便用户知道发生了什么事情,否则它看起来就像刚刚挂起。
所以我有这个:
- (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex (NSInteger)buttonIndex {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
// yada, yada, yada
[self presentModalViewController:picker animated:YES];
[picker release];
}
然后当用户选择“使用”时调用它:
- (void) imagePickerController: (UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissModalViewControllerAnimated:YES];
[self performSelectorOnMainThread:@selector(processImage:) withObject:info waitUntilDone:NO];
animate = true;
}
然后在缩略图旋转时调用它来执行处理:
- (void) processImage:(NSDictionary *)info
{
UIImage *image = nil;
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
// processing of image
animate = false;
[activityImageView stopAnimating];
[activityImageView release];
[self.tableView reloadData];
}
就像我说的,它在 iOS4 上完美运行,但在 iOS5 上,就没有这样的运气了。那么有什么关系呢?图像选择器最终会被关闭,为什么不立即关闭呢?
【问题讨论】:
-
我真的不知道为什么这很重要,但是您是否尝试将
[self performSelector...替换为dispatch_async(dispatch_get_main_queue(), ^{[self processImage:info];});? -
好主意,但行为相同。至少我学到了一些新东西!
标签: ios5 uiimagepickercontroller spinner dismiss