UIKit provides access to a device’s camera through the UIImagePickerController class. This class displays the standard system interface for taking pictures using the available camera. It also supports optional controls for resizing and cropping the image after the user takes it. This class can also be used to select photos from the user’s photo library.
The view representing the camera interface is a modal view that is managed by the UI Image Picker Controller class. You should never access this view directly from your code. To display it, you must call the present Modal View Controller: animated: method of the currently active view controller, passing a UI Image Picker Controller object as the new view controller. Upon being installed, the picker controller automatically slides the camera interface into position, where it remains active until the user approves the picture or cancels the operation. At that time, the picker controller notifies its delegate of the user’s choice.
Interfaces managed by the UI Image Picker Controller class may not be available on all devices. Before displaying the camera interface, you should always make sure that the interface is available by calling the is Source Type Available: class method of the UI Image Picker Controller class. You should always respect the return value of this method. If this method returns NO, it means that the current device does not have a camera or that the camera is currently unavailable for some reason. If the method returns YES, you display the camera interface by doing the following:
In most cases, the current view controller acts as the delegate for the picker, but you can use an entirely different object if you prefer. The delegate object must conform to the UIImagePickerControllerDelegate and UINavigationControllerDelegate protocols.
Listing shows the code representing the preceding set of steps. As soon as you call the present Modal View Controller: animated method, the picker controller takes over, displaying the camera interface and responding to all user interactions until the interface is dismissed. To choose an existing photo from the user’s photo library, all you have to do is change the value in the source Type property of the picker to UI Image Picker Controller Source Type Photo Library.
Displaying the interface for taking pictures
When the user taps the appropriate button to dismiss the camera interface, the UI Image Picker Controller notifies the delegate of the user’s choice but does not dismiss the interface. The delegate is responsible for dismissing the picker interface. (Your application is also responsible for releasing the picker when done with it, which you can do in the delegate methods.) It is for this reason that the delegate is actually the view controller object that presented the picker in the first place. Upon receiving the delegate message, the view controller would call its dismiss Modal View Controller Animated: method to dismiss the camera interface.
Listing shows the delegate methods for dismissing the camera interface displayed in
Listing. These methods are implemented by a custom My ViewController class, which is a subclass of UI View Controller and, for this example, is considered to be the same object that displayed the picker in the first place. The use Image: method is an empty place holder for the work you would do in your own version of this class and should be replaced by your own custom code.
Delegate methods for the image picker
If image editing is enabled and the user successfully picks an image, the image parameter of the image Picker Controller: did Finish Picking Image: editingInfo: method contains the edited image. You should treat this image as the selected image, but if you want to store the original image, you can get it (along with the crop rectangle) from the dictionary in the editingInfo parameter.
IPHONE APPS Related Interview Questions
|C Interview Questions||IPHONE APPS Interview Questions|
|Mobile Testing Interview Questions||Oracle apps Interview Questions|
|Java Native Interface (JNI) Interview Questions||JNDI (Java Naming and Directory Interface) Interview Questions|
|Mobile computing Interview Questions||jQuery Mobile Interview Questions|
|Mobile Security Interview Questions||Objective C Interview Questions|
|Mobile Developer Interview Questions||Mobile Application Testing Interview Questions|
|Apps Associates Manual Testing Interview Questions||Mobile Marketing Interview Questions|
Iphone Apps Tutorial
The Core Application
Window And Views
Graphics And Drawing
Text And Web
Files And Networking
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.