Displaying a custom button on camera view

北战南征 提交于 2019-12-10 11:05:45

问题


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!

Edit

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?


回答1:


From the documentation for UIImagePickerController:

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

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.

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.



来源:https://stackoverflow.com/questions/9220872/displaying-a-custom-button-on-camera-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!