0
votes

When I'm trying to select images from camera rolls, I'm getting the following warning. (when I press the button camera rolls it goes to select albums page where we can select images from our phone).

Presenting view controllers on detached view controllers is discouraged

My didFinishLaunchingWithOptions method is like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


    [application setStatusBarHidden:YES];
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    [userDefault synchronize];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc] init];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = navigation;
    navigation.navigationBarHidden = YES;

    [self.window makeKeyAndVisible];
}

My camera button code is:

- (void)cameraButtonSelected
{

ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName:nil bundle:nil];
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
[albumController setParent:elcPicker];
[elcPicker setDelegate:self];

AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[app.viewController presentViewController:elcPicker animated:YES completion:nil];
[self.view.window.rootViewController.navigationController pushViewController:elcPicker animated:YES];
   }
2
At first, Please format your snippet in well manner.VRAwesome
Where is your code of selecting image from camera rolls ?VRAwesome
Yeah, here i added code for camera method pls check it once...Boyapati Sravani

2 Answers

0
votes

In your ViewController or ViewDidAppear method write your camera method.

0
votes

Here, you are trying to present picker as well as push , both at a time.

Either push your picker or present it.

And if you are present or push it from any view controller then just write :

Either

[self presentViewController:elcPicker animated:YES completion:nil];

Or

[self.navigationController pushViewController:elcPicker animated:YES];