簡體   English   中英

ios imagepickerview取消按鈕功能

[英]ios imagepickerview cancel button functionality

我的“取消”按鈕反正拉起相機膠卷。 我該如何刪除。

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

您需要更好的操作表按鈕處理:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM