2013-02-21 71 views
0

我的取消按鈕正在拉起相機卷。我如何刪除它。ios imagepickerview取消按鈕功能

- (void)cameraButtonClick:(id)sender { 
     mediaPicker = [[UIImagePickerController alloc] init]; 
     //[mediaPicker setDelegate:self]; 
     mediaPicker.allowsEditing = YES; 
     if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
      UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                    delegate:self 
                  cancelButtonTitle:@"Cancel" 
                 destructiveButtonTitle:nil 
                  otherButtonTitles:@"Take photo", @"Choose Existing", nil]; 
      [actionSheet showInView:self.view]; 
     } 
     // If device doesn't has a camera, Only "Choose Existing" option will show up. 
     else { 
      UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                    delegate:self 
                  cancelButtonTitle:@"Cancel" 
                 destructiveButtonTitle:nil 
                  otherButtonTitles:@"Choose Existing", nil]; 
      [actionSheet showInView:self.view]; 

     } 
    } 


- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

     if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
      if (buttonIndex == 0) { 
       [capture showImagePicker:self.navigationController popoverRect:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; 
      } else if (buttonIndex == 1) { 
       capture  = [[VFPhotoCaptureController alloc] init]; 
      } 
     } 
     else{ 
      if (buttonIndex == 0) { 
       capture  = [[VFPhotoCaptureController alloc] init]; 
      } 

     } 
     [self presentModalViewController:mediaPicker animated:YES]; 
    } 

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 
     [picker dismissModalViewControllerAnimated:YES]; 
    } 

回答

0

你需要更好的動作片按鈕操作:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex != actionSheet.cancelButtonIndex) { 
     if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
      if (buttonIndex == actionSheet.firstOtherButtonIndex) { 
       [capture showImagePicker:self.navigationController popoverRect:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; 
      } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) { 
       capture = [[VFPhotoCaptureController alloc] init]; 
      } 
     } else { 
      if (buttonIndex == actionSheet.firstOtherButtonIndex) { 
       capture = [[VFPhotoCaptureController alloc] init]; 
      } 
     } 

     [self presentModalViewController:mediaPicker animated:YES]; 
    } 
} 
+0

感謝澄清。我只是想出了問題是最後一行[self presentModalViewController:mediaPicker animated:YES];這真是愚蠢的我。我確實在代碼中加入了您的更改。 – CalZone 2013-02-21 19:16:03