简体   繁体   中英

iPhone - UIImagePickerController - How to allow user to pick the source?

I'm writing an application that uses UIImagePickerController. I'd like to give users choice of source of pictures, either take a new photo or choose from existing ones. I'd like to create exactly the same selection interface as is in twitterfon or in safari when you hold tap on the link. It looks like some standard SDK thing but I have completely no clue where to find some sample code. I've googled for hours and I have nothing.

I would really appreciate any tips. Thank you

What you're looking for is the UIActionSheet. The documentation has everything you need to set one up and how to respond to which button is pressed.

You'll also want to use the constants defined for the UIImagePickerController sources, namely

UIImagePickerControllerSourceTypeCamera
UIImagePickerControllerSourceTypePhotoLibrary

That would be an UIActionSheet . Make sure to point its delegate property to your implementation of the UIActionSheetDelegate protocol to catch clicks on the buttons you define.

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