Objective c 如何在UIImagePickerController popover中添加自定义按钮

Objective c 如何在UIImagePickerController popover中添加自定义按钮,objective-c,xamarin.ios,Objective C,Xamarin.ios,当我从gallery中选择图像时,如何在UIImagePickerControllerpopover中添加自定义按钮。默认情况下,这些按钮是Apple为UIImagePickerViewController提供的。因此,您必须使用一个属性,该属性是allowsdediting。您必须将其设置为YES 因此,从gallery或camera中选择照片后,将显示这两个按钮 代码应该类似于: -(void)openGallery { UIImagePickerController *picke

当我从gallery中选择图像时,如何在
UIImagePickerController
popover中添加自定义按钮。默认情况下,这些按钮是Apple为UIImagePickerViewController提供的。因此,您必须使用一个属性,该属性是
allowsdediting
。您必须将其设置为
YES

因此,从gallery或camera中选择照片后,将显示这两个按钮

代码应该类似于:

-(void)openGallery {

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
}

-(void)openCamera {
    BOOL isCameraPresent = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
    if(isCameraPresent) {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;

        // Add overlay view with custom button on it. Set frames to button as per your choice.
        UIView *viewOverlay = [[UIView alloc]initWithFrame:self.view.bounds];
        Create and initialise your `UIButton` here
        [viewOverlay addSubview:YOUR_BUTTON_OBJECT];

        picker.cameraOverlayView = viewOverlay;

        [self presentViewController:picker animated:YES completion:NULL];
    }
    else {
        NSLog(@"Camera not present");
    }
}
只有当
sourceType
UIImagePickerController源类型Camera
时,才能添加覆盖

确保已在视图控制器中确认
UIImagePickerControllerDelegate
协议

根据您的选择,点击按钮或操作表操作时调用这些操作


注意:UIImagePickerController的popover的UI取决于设备的iOS版本。明白了。默认情况下,这些按钮是Apple为UIImagePickerViewController提供的。因此,您必须使用一个属性,该属性是
allowsdediting
。您必须将其设置为
YES

因此,从gallery或camera中选择照片后,将显示这两个按钮

代码应该类似于:

-(void)openGallery {

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:picker animated:YES completion:NULL];
}

-(void)openCamera {
    BOOL isCameraPresent = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
    if(isCameraPresent) {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;

        // Add overlay view with custom button on it. Set frames to button as per your choice.
        UIView *viewOverlay = [[UIView alloc]initWithFrame:self.view.bounds];
        Create and initialise your `UIButton` here
        [viewOverlay addSubview:YOUR_BUTTON_OBJECT];

        picker.cameraOverlayView = viewOverlay;

        [self presentViewController:picker animated:YES completion:NULL];
    }
    else {
        NSLog(@"Camera not present");
    }
}
只有当
sourceType
UIImagePickerController源类型Camera
时,才能添加覆盖

确保已在视图控制器中确认
UIImagePickerControllerDelegate
协议

根据您的选择,点击按钮或操作表操作时调用这些操作


注意:UIImagePickerController的popover的用户界面取决于设备的iOS版本。

您能用其中的设计图像更新问题吗?确切地说,您想要构建什么用户界面。在我从gallery中选择图像后,我需要图像选择器中的这些按钮。您可以用其中的设计图像更新问题吗?这正是您想要构建的UI。在我从gallery中选择图像后,我需要ImagePickerHanks@Pushkraj中的这些按钮,如果我想在这些方法中再添加一个按钮,我如何继续。这是我的需要。不,我不想在打开相机时添加覆盖,我需要在打开GalleryThank@Pushkraj的图像时添加覆盖,如果我想在这些方法中添加一个按钮,我如何继续。这是我的需要。不,我不想在打开相机时添加覆盖,我需要在打开画廊中的图像时添加覆盖