Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController push viewcontroller bug with allowsEditing

Tags:

ios

I am trying to push a view controller (for extra editing) from UIImagePickerController after user has selected an image.
It is successfully pushed. But when that view controller is popped and user return to the editing screen, the editing screen is no longer interactable. Does anyone know what is the problem.

    -(void)didTapBtn:(id)sender
        {
            self.picker = [[UIImagePickerController alloc] init];
            self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            self.picker.delegate = self;
            self.picker.allowsEditing = YES;

            [self presentViewController:self.picker animated:YES completion:nil];
        }

        -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
        {
            UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];

            if (image == nil) {
                image = [info objectForKey:UIImagePickerControllerOriginalImage];
            }

            if (image == nil) {
                return;
            }



           self.test = [[BTTestViewController alloc] init];
            self.test.delegate = self;

            [self.picker pushViewController:self.test animated:YES];
        }

//Called by BTTestViewController
        -(void)didCancel
        {
            [self.picker popViewControllerAnimated:YES];
        }
like image 481
wjh Avatar asked Nov 12 '22 19:11

wjh


1 Answers

try this one it work in my application:

   UIImagePickerController *imagePicker;//put it in .h file

 put it in .m file 
       imagePicker = [[UIImagePickerController alloc]init];
       imagePicker.delegate = self;

        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
             imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
             imagePicker.allowsEditing = YES;
              [self presentViewController:imagePicker animated:YES completion:nil];
        }
        else
        {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"STEP-BY-STEP-STORY!" message: @"Camera is not available" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
              [alert show];

        }

     - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
         {
           UIImage *pickedImage = [info objectForKey:UIImagePickerControllerEditedImage];
           imageData.image =[self resizeImage:imageData.image width:200 height:200];
            [picker dismissViewControllerAnimated:YES completion:nil];

           iphone_filtersViewController *nav=[[iphone_filtersViewController alloc]initWithNibName:@"iphone_filtersViewController" bundle:nil];
           [self.navigationController pushViewController:nav animated:YES];

      }
      - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
      {
        // release Picker
         [picker dismissViewControllerAnimated:YES completion:nil];
      }

    // iphone_filtersViewController method
      -(IBAction)backButton
        {
           [self.navigationController popViewControllerAnimated:YES];
        }

may be it will help.

like image 154
Dhaval Bhadania Avatar answered Nov 15 '22 06:11

Dhaval Bhadania