Application tried to present modally active controller: UIImagePickerController

I have been fighting for this for 2 days and I believe that this is the moment when I should ask for help. After I searched for SOF for a while, none of the answers could solve my problem. Here is my application ...

In the application

  • IPad device, iOS 6
  • RootViewController is a NavigationController
  • TopViewController is a TabBarController
  • In this TabBarController, I present the popoverController from the right pane in the navigation bar
  • When presenting popover, there is a button that allows the user to select an image, taking a new one or selecting one from existing ones.
  • To select a new one, I introduce the ViewController UIImagePickerController to allow the user to take photos using the camera. presentModalViewController: animated: if iOS <6 and presentViewController: animated: completion: for iOS> 6
  • I also hide the status bar before the view
  • To select an existing photo, I make presentPopoverFromBarButtonItem: allowArrowDirections: animated:
  • PopoverViewController also refers to TabBarController

Here is the problem

  • UIImagePickerController , " < [ , ] > "
  • , , , .

  • RootViewController
  • TopViewController (TabBarController)
  • popoverViewController
  • TabBarController
  • popoverViewController
  • resignFirstResponder popoverViewController

,

// PopoverViewController, presented by a tab in TabBarController
- (IBAction)takePhoto:(id)sender {
    [self.delegate takePhotoWithDeviceCamera];
}

// A Tab in TabBarController, delegate of popoverViewController
- (void)takePhotoWithCamera {
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    if ([UIDevice OSVersion] < 6.0) {
        [self presentModalViewController:cameraPicker animated:YES];
    } else {
        [self presentViewController:cameraPicker animated:YES completion:nil];
    }
}

, ? . .

+5
5

imagePicker popoverController ( iPad). .

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popOver = popover;
} 
else {
[self presentModalViewController:picker animated:YES];
}

.

+4

, , , , , @CainaSouza. Xamarin.iOS, #, Objective-C.

, @CainaSouza, :

UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (customController, true, null);

RootViewController:

public override void PresentViewController (UIViewController viewControllerToPresent, bool animated, Action completionHandler)
{
    if (PresentedViewController != viewControllerToPresent) {
        base.PresentViewController (viewControllerToPresent, animated, completionHandler);
    }
}

, , UIViewController.

, , , -.:)

+4

?

[self.view.window.rootViewController presentModalViewController:cameraPicker animated:YES];
+2

, CameraPicker /. cameraPicker (void) takePhotoWithCamera , . picker ...

0

- , (.. presentViewController UIImagePickerController) popover ( popover initWithContentViewController). UIImagePickerController popover, , , popover.

, UIImagePickerController - ( ) popover. .:-)

, - , , , , .

0
source

All Articles