80 likes | 230 Views
iOS Photo API. North Atlanta iOS Developers Meetup 05/10/2012. Overview. Hopefully this presentation might inspire one to develop the next InstaGram . If you do, and your app becomes a success – please remember all of us at the Meetup Group.
E N D
iOS Photo API North Atlanta iOS Developers Meetup 05/10/2012
Overview Hopefully this presentation might inspire one to develop the next InstaGram. If you do, and your app becomes a success – please remember all of us at the Meetup Group. The good news is that taking Photos from the Camera is easy.
UIImagePickerController UIImagePickerController is the iOS class that is responsible for launching the Camera and Photo picker dialogs. UIImagePickerControllerDelegate is a delegate class that is used to indicate that a Photo or Image has been chosen or not chosen.
PhotoGram app At this point I will walk you through the PhotoGram app. For more details on the UIImagePickerController class and Delegate, the Apple documentionis useful.
Summary of PhotoGram app 1) In your ViewController’s header, you should declare that it implements the UIImagePickerControllerDelegate and UINavigationControllerDelegate Question: Normally one only declares 1 delegate. Why is UINavigationControllerDelegate required as well?
Summary of PhotoGram app 2) In response to a button click (refer to takePhotoFromCamera method) a) Create UIImagePickerController object b) Optionally set it to allow Editing c) Set Source Type (UIImagePickerControllerSourceTypeCamera) d) Set Delegate e) Present UIImagePicker modally
Summary of PhotoGram app 3) Implement UIImagePickerController delegate methods. Inside the didFinishPickingMediaWithInfo method get the UIImage, do whatever processing required for your app, and dismiss controller
Summary of PhotoGram app The processing in the PhotoGram app is to save the Image to a file in the Documents directory named with the current system time (This should be unique) – and then displays the image on the Image View Question: Why should the image be persisted (stored to file) – if all we are going to is display it?