4

フォト ライブラリから UIImagePickerController インターフェイスを介して画像を選択した後、 imagePickerController:didFinishPickingImage:editingInfoDismissModelViewControllerAnimated を呼び出したにもかかわらず、フォト ライブラリ ビューが表示されたままになります。

誰もこれを見たことがありますか?これらは、私が使用している 3 つの関連する方法です。

- (IBAction)choosePictureFromLibrary:(id)sender {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        UIImagePickerController* picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsImageEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    else {
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error accessing Photo Library" message:@"This device does not support a Photo Library." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}


- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo {   
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Picture picked!" message:@"You picked a picture!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];

    [picker dismissModalViewControllerAnimated:YES];
}


- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker {   
    [picker dismissModalViewControllerAnimated:YES];
}

imagePickerController:didFinishPickingImage:editingInfo を呼び出すとフォト ライブラリ ビューが完全に閉じられると思っていましたが、そうではないようです。それをなくすために私がしなければならないことは他にありますか?

4

3 に答える 3

6

ピッカー自体ではなく、ピッカーの viewController にアクセスする必要があります。代わりにこの行を試してください。

[[picker parentViewController] dismissModalViewControllerAnimated:YES];
于 2009-03-25T19:34:30.673 に答える
3

あなたはただ呼び出すことができます

[self dismissModalViewControllerAnimated:YES];

現在のビューの上にあるモーダルビューコントローラーを閉じるには。

これは、次の呼び出しによってViewControllerを提示するので意味があります。

[self presentModalViewController:picker animated:YES];
于 2009-06-03T21:38:22.097 に答える
1

これに対する回答の更新のみ

 [self dismissModalViewControllerAnimated:YES];

で非推奨になったiOS 6.0ため、使用する必要があります。

 [self dismissViewControllerAnimated:YES completion:nil];

大きな変更ではありませんが、この質問を見て iOS 6.0 を使用している場合は、更新された回答が必要になります。

 [self presentModalViewController:filePicker animated:YES];

また、推奨されていません

 [self presentViewController:filePicker animated:YES completion:nil];
于 2012-12-06T12:35:23.603 に答える