Zoltan Varadi
Zoltan Varadi

Reputation: 2488

ios pushViewController from imagePickerController: didFinishPickingMediaWithInfo

in my app after i take a photo with the camera i want to navigate to an other viewcontroller in

didFinishPickingMediaWithInfo

Right now, i'm doing it in the dismissViewControllerAnimated function's completition block, but i don't feel like it's the most elegant way to do it. Could you tell me how this could be done better? Here's the exact code

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *mediaType = info[UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
        UIImage *image = [info[UIImagePickerControllerOriginalImage] scaledCopyOfSize:CGSizeMake(175.0f, 175.0f)];


        [self dismissViewControllerAnimated:YES completion:^(void){
            setVC = [[SetVCr alloc]init];

            [[self navigationController]pushViewController:seVC animated:YES];
        }];   
    }   
}

Upvotes: 2

Views: 938

Answers (2)

DrPatience
DrPatience

Reputation: 1776

I suggest setting your completion block to nil and on the next line call the 'performSegueWithIdentifier' method as written below:

[self performSegueWithIdentifier:@"segueToNewcontroller" sender:self];

Upvotes: 0

Alexey
Alexey

Reputation: 7247

You can push new view controller directly from the picker

  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        NSString *mediaType = info[UIImagePickerControllerMediaType];

        if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
            UIImage *image = [info[UIImagePickerControllerOriginalImage]  scaledCopyOfSize:CGSizeMake(175.0f, 175.0f)];
            setVC = [[SetVCr alloc]init];
           [picker pushViewController:seVC animated:YES];//you can push new view controller directly from the picker
        }   
    }

Upvotes: 1

Related Questions