在相机视图上显示自定义按钮 [英] Displaying a custom button on camera view

查看:135
本文介绍了在相机视图上显示自定义按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如果有一个方法来贴在相机视图上的自定义按钮,以允许用户从他们的库中选择一张照片,如oink或instagram没有做一个自定义视图?非常感谢!

Does anyone know if there's a way to stick a custom button on the camera view to allow a user to select a photo from their library like oink or instagram does without making a custom view? Thanks!

编辑

有谁知道如何实际显示照片库从那里,并使用人选择什么?

Adding the button seems easy with the overlay; does anyone know how to actually display the photo library from there and use what the person selects?

推荐答案

从UIImagePickerController的文档:

From the documentation for UIImagePickerController:


您可以自订图片选择器控制器,自行管理使用者
的互动。为此,请提供一个重叠视图,其中包含
您要显示的控件,并使用
捕获静态图片或电影中描述的方法。您可以显示自定义
重叠视图除了或替代默认控件。

UIImagePickerController类的自定义叠加视图是
可用在iOS 3.1和更高版本通过cameraOverlayView
属性。有关代码示例,请参阅PhotoPicker示例代码项目。

You can customize an image picker controller to manage user interactions yourself. To do this, provide an overlay view containing the controls you want to display, and use the methods described in "Capturing Still Images or Movies." You can display your custom overlay view in addition to, or instead of, the default controls. Custom overlay views for the UIImagePickerController class are available in iOS 3.1 and later by way of the cameraOverlayView property. For a code example, see the PhotoPicker sample code project.

https://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/ UIImagePickerController.html

您为照片库按钮选择的代理也应该可以访问UIImagePickerController。然后,当按下相册的按钮时,您可以在UIImagePickerController上调用presentModalViewController:animated:(或presentViewController:animated:completion:如果您要定位iOS 5及以上版本),传入一个新的UIImagePickerController,将sourceType设置为UIImagePickerControllerSourceTypePhotoLibrary。

The delegate you choose for your photo library button should also have access to the UIImagePickerController. Then, when the button is pressed for photo album, you can call presentModalViewController:animated: (or presentViewController:animated:completion: if you are targeting iOS 5 and up) on the UIImagePickerController, passing in a new UIImagePickerController with sourceType set to UIImagePickerControllerSourceTypePhotoLibrary.

我已经通过两种方式处理了这个问题:第一,只是使用UIActionSheet在显示图像选择器之前提示用户;第二,在选项卡控制器或其他容器控制器中托管选择器。

I've handled this issue in two other ways: 1st, just use a UIActionSheet to prompt the user prior to showing the image picker; 2nd, host the pickers in a tab controller or other container controller.

这篇关于在相机视图上显示自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆