2013-10-25 57 views
5

我想在用戶選擇圖像後從UIImagePickerController推視圖控制器(用於額外的編輯)。
它被成功推送。 但是,當視圖控制器彈出並且用戶返回到編輯屏幕時,編輯屏幕不再可交互。有誰知道是什麼問題。UIImagePickerController推送viewcontroller錯誤允許編輯

-(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]; 
     } 

回答

1

試試這個在我的應用程序中工作:

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]; 
     } 

可能會有所幫助。

+0

我想要的是,當用戶按取消,它會回到照片/相機屏幕。在你的方法中,選取器已被解僱。所以這不是我想要的。 – wjheng