2015-12-22 44 views
0
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
imagePicker.delegate = self; 
imagePicker.allowsEditing = YES; 

switch (buttonIndex) { 
    case 0: 
    { 
     imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
     imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
     [self presentViewController:imagePicker animated:YES completion:nil]; 
    } 
     break; 
    case 1: 
    { 
     imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     [self presentViewController:imagePicker animated:YES completion:nil]; 
    } 
     break; 
    case 2: 
    { 
     [actionSheet removeFromSuperview]; 
    } 
      break; 
     default: 
      break; 
    } 
} 

當我拍照不能拖動照片,但照片UIImagePickerControllerSourceTypePhotoLibrary可以編輯的UIImagePickerController allowsEditing = YES不工作

enter image description here

回答

0

試試這個代碼。它在我的前後攝像模式下工作。 UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self;

if (buttonIndex==0) { 
     if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
      imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
      imagePicker.mediaTypes = @[(NSString *) kUTTypeImage]; 
      imagePicker.allowsEditing = YES; 
      [self presentViewController:imagePicker animated:YES completion:nil]; 

     } 

    } 
+0

它不起作用,謝謝你們一樣 – liuqing

相關問題