我有一個UITableViewController彈出一個UIImagePickerController,用戶需要一個圖片,點擊使用按鈕,Picker關閉顯示一個自定義的縮略圖旋轉器,而圖像正在處理,然後微調器被替換爲實際縮略圖在結束處理。爲什麼不會dismissmodalviewcontrolleranimated立即關閉ios5的UIImagePickerController?
至少這就是它在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一樣,沒有這樣的運氣。那麼交易是什麼?圖像採集器最終被解僱,爲什麼它不會立即被解僱?
我真的不知道爲什麼它應該沒關係,但是你試過更換'[自performSelector ...'和'dispatch_async (dispatch_get_main_queue(),^ {[self processImage:info];});'? – NJones
好想法,但同樣的行爲。至少我學到了新東西! – mutatron