標準のカメラ ロールの写真ピッカーを表示するために、presentViewController
を使用しようとしています。UIImagePickerControl
これは、私のアプリのほとんどでエンドツーエンドで機能します。それが機能しない場所は、すでに提示されているviewController
;内で imagePicker を使用したい場合です。アルバムを表示するビューを表示できません。
rootViewController
基本的な考え方は、ウィンドウ オブジェクトまたはアプリ デリゲートの永続tabBarController
化 (つまり) にアクセスしようとしているということですrootViewController
。どちらも、できれば常に存在するトップ レベルのアイテムの例です。そうでなければ、「自己」を使用するだけでは、それを提示する部分的なビューになってしまいます。
presentViewController
既にpresentedView内に信頼できる方法はありますか?
dispatch_async(dispatch_get_main_queue(), ^ {
// 1. attempt that works well elsewhere in app
[((AppDelegate*)[[UIApplication sharedApplication] delegate]).tabBarController presentViewController:self.imagePickerController animated:YES completion:nil];
// 2. this does nothing, no crash or action (_UIAlertShimPresentingViewController)
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:self.imagePickerController animated:YES completion:nil];
// 3. attempt off related internet suggestion, nothing happens
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
[topController presentViewController:self.imagePickerController animated:YES completion:nil];
});