Class: UIImagePickerController

Inherits:
UINavigationController show all

Overview

The UIImagePickerController class manages customizable, system-supplied user interfaces for taking pictures and movies on supported devices, and for choosing saved images and movies for use in your app. An image picker controller manages user interactions and delivers the results of those interactions to a delegate object.

Instance Attribute Summary (collapse)

Attributes inherited from UINavigationController

#navigationBar, #navigationBarHidden, #toolbar, #toolbarHidden, #topViewController, #viewControllers, #visibleViewController

Attributes inherited from UIViewController

#childViewControllers, #contentSizeForViewInPopover, #definesPresentationContext, #editing, #hidesBottomBarWhenPushed, #interfaceOrientation, #modalInPopover, #modalPresentationStyle, #modalTransitionStyle, #navigationController, #navigationItem, #nibBundle, #nibName, #parentViewController, #presentedViewController, #presentingViewController, #providesPresentationContextTransitionStyle, #restorationClass, #restorationIdentifier, #searchDisplayController, #splitViewController, #storyboard, #tabBarController, #tabBarItem, #title, #toolbarItems, #view, #wantsFullScreenLayout

Attributes inherited from UIResponder

#inputAccessoryView, #inputView, #undoManager

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from UINavigationController

#initWithNavigationBarClass:toolbarClass:, #initWithRootViewController:, #popToRootViewControllerAnimated:, #popToViewController:animated:, #popViewControllerAnimated:, #pushViewController:animated:, #setNavigationBarHidden:animated:, #setToolbarHidden:animated:, #setViewControllers:animated:

Methods inherited from UIViewController

#addChildViewController:, attemptRotationToDeviceOrientation, #beginAppearanceTransition:animated:, #canPerformUnwindSegueAction:fromViewController:withSender:, #decodeRestorableStateWithCoder:, #didMoveToParentViewController:, #didReceiveMemoryWarning, #didRotateFromInterfaceOrientation:, #disablesAutomaticKeyboardDismissal, #dismissViewControllerAnimated:completion:, #editButtonItem, #encodeRestorableStateWithCoder:, #endAppearanceTransition, #initWithNibName:bundle:, #isBeingDismissed, #isBeingPresented, #isMovingFromParentViewController, #isMovingToParentViewController, #isViewLoaded, #loadView, #performSegueWithIdentifier:sender:, #preferredInterfaceOrientationForPresentation, #prepareForSegue:sender:, #presentViewController:animated:completion:, #removeFromParentViewController, #rotatingFooterView, #rotatingHeaderView, #segueForUnwindingToViewController:fromViewController:identifier:, #setEditing:animated:, #setToolbarItems:animated:, #shouldAutomaticallyForwardAppearanceMethods, #shouldAutomaticallyForwardRotationMethods, #shouldAutorotate, #shouldPerformSegueWithIdentifier:sender:, #supportedInterfaceOrientations, #transitionFromViewController:toViewController:duration:options:animations:completion:, #updateViewConstraints, #viewControllerForUnwindSegueAction:fromViewController:withSender:, #viewDidAppear:, #viewDidDisappear:, #viewDidLayoutSubviews, #viewDidLoad, #viewWillAppear:, #viewWillDisappear:, #viewWillLayoutSubviews, #willAnimateRotationToInterfaceOrientation:duration:, #willMoveToParentViewController:, #willRotateToInterfaceOrientation:duration:

Methods inherited from UIResponder

#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- ( (nonatomic) BOOL ) allowsEditing

A Boolean value indicating whether the user is allowed to edit a selected still image or movie. If you allow the user to edit still images or movies, the delegate may receive a dictionary with information about the edits that were made. The protocol for the delegate is described in UIImagePickerControllerDelegate Protocol Reference.This property is set to NO by default.

Returns:

  • ( (nonatomic) BOOL )

- ( (nonatomic) UIImagePickerControllerCameraCaptureMode ) cameraCaptureMode

The capture mode used by the camera. The various capture modes are listed in the “UIImagePickerControllerCameraCaptureMode” enumeration. The default value is UIImagePickerControllerCameraCaptureModePhoto.

Returns:

  • ( (nonatomic) UIImagePickerControllerCameraCaptureMode )

- ( (nonatomic) UIImagePickerControllerCameraDevice ) cameraDevice

The camera used by the image picker controller. The default is UIImagePickerControllerCameraDeviceRear.

Returns:

  • ( (nonatomic) UIImagePickerControllerCameraDevice )

- ( (nonatomic) UIImagePickerControllerCameraFlashMode ) cameraFlashMode

The flash mode used by the active camera. The various flash modes are listed in the “UIImagePickerControllerCameraFlashMode” enumeration. The default value is UIImagePickerControllerCameraFlashModeAuto.The value of this property specifies the behavior of the still-image flash when the value of the cameraCaptureMode property is UIImagePickerControllerCameraCaptureModePhoto, and specifies the behavior of the video torch when cameraCaptureMode is UIImagePickerControllerCameraCaptureModeVideo.

Returns:

  • ( (nonatomic) UIImagePickerControllerCameraFlashMode )

- ( (nonatomic, retain) UIView ) cameraOverlayView

The custom view to display on top of the default image picker interface. You can use an overlay view to present a custom view hierarchy on top of the default image picker interface. The image picker layers your custom overlay view on top of the other image picker views and positions it relative to the screen coordinates. If you have the default camera controls set to be visible, incorporate transparency into your view, or position it to avoid obscuring the underlying content.This property is set to nil by default.You can access this property only when the source type of the image picker is set to UIImagePickerControllerSourceTypeCamera. Attempting to access this property for other source types results in the throwing of an NSInvalidArgumentException exception.

Returns:

  • ( (nonatomic, retain) UIView )

- ( (nonatomic) CGAffineTransform ) cameraViewTransform

The transform to apply to the camera’s preview image. This transform affects the live preview image only and does not affect your custom overlay view or the default image picker controls. You can use this property in conjunction with custom controls to implement your own electronic zoom behaviors.You can access this property only when the source type of the image picker is set to UIImagePickerControllerSourceTypeCamera. Attempting to access this property for other source types results in the throwing of an NSInvalidArgumentException exception.

Returns:

- (Object) delegate

The image picker’s delegate object. The delegate receives notifications when the user picks an image or movie, or exits the picker interface. The delegate also decides when to dismiss the picker interface, so you must provide a delegate to use a picker. If this property is nil, the picker is dismissed immediately if you try to show it.For information about the methods you can implement for your delegate object, see UIImagePickerControllerDelegate Protocol Reference.

Returns:

- ( (nonatomic, copy) NSArray ) mediaTypes

An array indicating the media types to be accessed by the media picker controller. Depending on the media types you assign to this property, the picker displays a dedicated interface for still images or movies, or a selection control that lets the user choose the picker interface. Before setting this property, check which media types are available by calling the availableMediaTypesForSourceType: class method.If you set this property to an empty array, or to an array in which none of the media types is available for the current source, the system throws an exception.When capturing media, the value of this property determines the camera interface to display. When browsing saved media, this property determines the types of media presented in the interface.By default, this property is set to the single value kUTTypeImage, which designates the still camera interface when capturing media, and specifies that only still images should be displayed in the media picker when browsing saved media. To designate the movie capture interface, or to indicate that only movies should be displayed when browsing saved media, use the kUTTypeMovie identifier in a statement like this:To designate all available media types for a source, use a statement like this:

Returns:

- ( (nonatomic) BOOL ) showsCameraControls

Indicates whether the image picker displays the default camera controls. The default value of this property is YES, which specifies that the default camera controls are visible in the picker. Set it to NO to hide the default controls if you want to instead provide a custom overlay view using the cameraOverlayView property. Note: In iOS 3.1.3 and earlier, hiding the default camera controls limits you to taking still pictures only, regardless of whether movie capture is available on the device.If you set this property to NO and provide your own custom controls, you can take multiple pictures before dismissing the image picker interface. However, if you set this property to YES, your delegate must dismiss the image picker interface after the user takes one picture or cancels the operation.You can access this property only when the source type of the image picker is set to UIImagePickerControllerSourceTypeCamera. Attempting to access this property for other source types results in the throwing of an NSInvalidArgumentException exception. Depending on the value you assign to the mediaTypes property, the default controls display the still camera or movie camera interface, or a selection control that lets the user choose the picker interface.

Returns:

  • ( (nonatomic) BOOL )

- ( (nonatomic) UIImagePickerControllerSourceType ) sourceType

The type of picker interface to be displayed by the controller. Prior to running the picker interface, set this value to the desired source type. The source type you set must be available and an exception is thrown if it is not. If you change this property while the picker is visible, the picker interface changes to match the new value in this property.The various source types are listed in the “UIImagePickerControllerSourceType” enumeration. The default value is UIImagePickerControllerSourceTypePhotoLibrary.

Returns:

  • ( (nonatomic) UIImagePickerControllerSourceType )

- ( (nonatomic) NSTimeInterval ) videoMaximumDuration

The maximum duration, in seconds, for a video recording. The default value for this property is 10 minutes (600 seconds). When a user taps the Share button to send a movie to MMS, MobileMe, YouTube, or another destination, an appropriate duration limit and an appropriate video quality are enforced.This property is available only if the mediaTypes property’s value array includes the kUTTypeMovie media type.

Returns:

  • ( (nonatomic) NSTimeInterval )

- ( (nonatomic) UIImagePickerControllerQualityType ) videoQuality

The video recording and transcoding quality. The video quality setting specified by this property is used during video recording. It is also used whenever picking a recorded movie. Specifically, if the video quality setting is lower than the video quality of an existing movie, displaying that movie in the picker results in transcoding the movie to the lower quality.The various video qualities are listed in the “UIImagePickerControllerQualityType” enumeration. The default value is UIImagePickerControllerQualityTypeMedium. To capture or transcode a movie using a video quality other than the default value, you must set the quality explicitly.This property is available only if the mediaTypes property’s value array includes the kUTTypeMovie media type.

Returns:

  • ( (nonatomic) UIImagePickerControllerQualityType )

Class Method Details

+ (Array) availableCaptureModesForCameraDevice(cameraDevice)

Returns an array of NSNumber objects indicating the capture modes supported by a given camera device. See “UIImagePickerControllerCameraCaptureMode” for possible values.

Parameters:

  • cameraDevice (UIImagePickerControllerCameraDevice)

    A “UIImagePickerControllerCameraDevice” constant indicating the camera you want to interrogate.

Returns:

  • (Array)

    An array of NSNumber objects indicating the capture modes supported by cameraDevice.

+ (Array) availableMediaTypesForSourceType(sourceType)

Returns an array of the available media types for the specified source type. Some iOS devices support video recording. Use this method, along with the isSourceTypeAvailable: method, to determine if video recording is available on a device. The availability of video recording is indicated by the presence of the kUTTypeMovie media type for the UIImagePickerControllerSourceTypeCamera source type.

Parameters:

  • sourceType (UIImagePickerControllerSourceType)

    The source to use to pick an image.

Returns:

  • (Array)

    An array whose elements identify the available media types for the specified source type.

+ (Boolean) isCameraDeviceAvailable(cameraDevice)

Returns a Boolean value that indicates whether a given camera is available.

Parameters:

  • cameraDevice (UIImagePickerControllerCameraDevice)

    A “UIImagePickerControllerCameraDevice” constant indicating the camera whose availability you want to check.

Returns:

  • (Boolean)

    YES if the camera indicated by cameraDevice is available, or NO if it is not available.

+ (Boolean) isFlashAvailableForCameraDevice(cameraDevice)

Indicates whether a given camera has flash illumination capability.

Parameters:

  • cameraDevice (UIImagePickerControllerCameraDevice)

    A “UIImagePickerControllerCameraDevice” constant indicating the camera whose flash capability you want to know.

Returns:

  • (Boolean)

    YES if cameraDevice can use flash illumination, or NO if it cannot.

+ (Boolean) isSourceTypeAvailable(sourceType)

Returns a Boolean value indicating whether the device supports picking media using the specified source type. Because a media source may not be present or may be unavailable, devices may not always support all source types. For example, if you attempt to pick an image from the user’s library and the library is empty, this method returns NO. Similarly, if the camera is already in use, this method returns NO.Before attempting to use an UIImagePickerController object to pick an image, you must call this method to ensure that the desired source type is available.

Parameters:

  • sourceType (UIImagePickerControllerSourceType)

    The source to use to pick an image or movie.

Returns:

  • (Boolean)

    YES if the device supports the specified source type; NO if the specified source type is not available.

Instance Method Details

- (Boolean) startVideoCapture

Starts video capture using the camera specified by the UIImagePickerControllerCameraDevice property. Use this method in conjunction with a custom overlay view to initiate the programmatic capture of a movie. You can take more than one movie without leaving the interface, but to do so requires you to hide the default image picker controls.Calling this method while a movie is being captured has no effect. You must call the stopVideoCapture method, and then wait until the associated delegate object receives an imagePickerController:didFinishPickingMediaWithInfo: message, before you can capture another movie.Calling this method when the source type of the image picker is set to a value other than UIImagePickerControllerSourceTypeCamera results in the throwing of an NSInvalidArgumentException exception.If you require additional options or more control over movie capture, use the movie capture methods in the AV Foundation framework. Refer to AV Foundation Framework Reference.

Returns:

  • (Boolean)

    YES on success or NO on failure. This method may return a value of NO for various reasons, among them the following:

- (Object) stopVideoCapture

Stops video capture. After you call this method to stop video capture, the system calls the image picker delegate’s imagePickerController:didFinishPickingMediaWithInfo: method.

Returns:

- (Object) takePicture

Captures a still image using the camera. Use this method in conjunction with a custom overlay view to initiate the programmatic capture of a still image. This supports taking more than one picture without leaving the interface, but requires that you hide the default image picker controls.Calling this method while an image is being captured has no effect. You must wait until the associated delegate object receives an imagePickerController:didFinishPickingMediaWithInfo: message before you can capture another picture.Calling this method when the source type of the image picker is set to a value other than UIImagePickerControllerSourceTypeCamera results in the throwing of an NSInvalidArgumentException exception.

Returns: