UIImagePickerController:如何添加按钮并选择照片

Posted

技术标签:

【中文标题】UIImagePickerController:如何添加按钮并选择照片【英文标题】:UIImagePickerController : How do I add button and select photo 【发布时间】:2013-05-23 15:28:28 【问题描述】:

如何添加按钮并选择照片。请帮忙告诉我如何解决

【问题讨论】:

帮帮我,我遇到麻烦了,SO 不接受这类问题。请展示您迄今为止所做的尝试,以使人们对您的问题感兴趣。 你好。我只想在 iphone 相机上添加按钮 【参考方案1】:

您需要创建一个 CustomOverlayView。然后像这样配置你的选择器:

    overlay = [[CustomOverlayView alloc]initWithFrame:self.view.bounds];
    overlay.delegate = self;
    picker = [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.navigationBarHidden = YES;
    picker.toolbarHidden = YES;
    picker.wantsFullScreenLayout = YES;
    picker.allowsEditing = YES;
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])

        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    
    else
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
    picker.showsCameraControls = NO;
    picker.cameraOverlayView = overlay;

【讨论】:

【参考方案2】:

这将起作用:

- (void)showImagePicker:(UIImagePickerControllerSourceType)source
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.sourceType = source;



    imgPicker.delegate = self;
    [self presentModalViewController:ipc animated:YES];

按钮按下动作:

- (IBAction)chooseImage:(id)sender 

    [self showImagePicker:UIImagePickerControllerSourceTypePhotoLibrary];


然后这样做:

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 

    [picker dismissViewControllerAnimated:YES completion:nil];

或通过正确的操作执行此代码

【讨论】:

问题是关于在左下角添加小图像预览。 你能帮我举个例子吗

以上是关于UIImagePickerController:如何添加按钮并选择照片的主要内容,如果未能解决你的问题,请参考以下文章

如何为照片库制作 UIImagePickerController 和我的问题

UIImagePickerController AVAudioPlayer

来自 UIImagePickerController 的强制方形图像

使用UIImagePickerController选择视频时调用的事件

SVG 覆盖在 UIImagePickerController 之上,UIImagePickerController 响应手势(iPhone/iOS)

UIImagePickerController 不是全屏