Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDee Greene
8,508 PointsPresenting both camera AND photo library
How would I go about presenting the camera to the user as well as an option to select a picture that is already stored on their device? Currently we are only doing one or the other.
1 Answer
Brayden Kness
12,492 PointsYou would have to make a custom view controller with the UIImagePickerControllerDelegate. Here is a good tutorial part 1 and part 2. Then you would add a button that could open the photo library.
P.S. Not in the tutorial but if you add a button in your storyboard then you to replace
cameraView.layer.addSublayer(previewLayer!)
with
cameraView.layer.insertSublayer(previewLayer!, atIndex: 0)
this will keep the buttons above the preview layer.
Dee Greene
8,508 PointsDee Greene
8,508 PointsThank you! Do you happen to know of any great tutorials like this that are in Objective-C since this is what the rest of the code is in
Brayden Kness
12,492 PointsBrayden Kness
12,492 PointsOh sorry didn't realize that. I will translate it and post it here in a little while.
Dee Greene
8,508 PointsDee Greene
8,508 Pointsthank you so much!
Brayden Kness
12,492 PointsBrayden Kness
12,492 PointsHere is an example project the only thing I didn't add is the code for pulling up the photo library but you will see the place to add it
Dee Greene
8,508 PointsDee Greene
8,508 Pointsthank you. this is nice. I'm sure i can mess w/ this to get it out how i want it. do you happen to know how to turn it to the front camera as well? and how would you capture a video?