なぜなdismissmodalviewcontrolleranimated任UIImagePickerControllerすぐios5を推奨?
-
29-10-2019 - |
質問
いUITableViewControllerッるUIImagePickerController、ユーザーはpic、ヒットのボタン、ピッカー免示カスタムサムネールスピンナーイメージがありましたが、現在処理中のスピンナーには実際のサムネイルの終処となります。
少なくともそうした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を推奨などを展開しております。でも読みました。画像ピッカーが棄却されず、が記載されていないのはなぜで取得退す。
解決
なんなのか理由があるものの格差 iOS4
& iOS5
このポイント。ものご説明はUI吊りはかなりのコードですよね。を行うセレクタのメインスレッドがこれこそが、舞台のセレクタはスレッドのスレッドだけ呼び出します。この設定 waitUntilDone:
へ NO
意味がないのでして、まず別のスレッドで実行す。いう結果を得たいから入れ替えのため、このように:
[self dismissModalViewControllerAnimated:YES];
animate = true;
[self performSelectorOnMainThread:@selector(processImage:) withObject:info waitUntilDone:NO];
ますのでご了承願いますこのことは危険で出来ていると思うの // processing of image
を含まないの並行処理.うブロックのための並行処理.それというネストしたインターロッキングブロックの並行処理で分かりやすく、例えば:
-(void)doSomeStuffInBackground{
// Prepare for background stuff
dispatch_async(dispatch_get_global_queue(0, 0), ^{
// Do background stuff
dispatch_async(dispatch_get_main_queue(), ^{
// Update UI from results of background stuff
});
});
}
それでは、これから、私はあなたが何かをつけることができます。:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissModalViewControllerAnimated:YES];
[self processImage:info];
}
-(void)processImage:(NSDictionary *)info{
animate = true;
UIImage *image = nil;
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
// processing of image here on background thread
dispatch_async(dispatch_get_main_queue(), ^{
// update UI here on main thread
animate = false;
[activityImageView stopAnimating];
[activityImageView release];
[self.tableView reloadData];
});
});
}
このことは日陰の主な業務バックグラウンドのスレッドのUI泊ます。
他のヒント
使用してみてください
[[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
それ以外の:
[[picker parentViewController] dismissModalViewControllerAnimated: YES];