简体   繁体   中英

Displaying a custom button on camera view

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM