iOS Development UI Foundation Uiimagepickercontroller Properties

Source: Internet
Author: User

Uiimagepickercontroller


1.+ (BOOL) issourcetypeavailable: (Uiimagepickercontrollersourcetype) sourcetype; Checks whether the specified source is available on the device.
Check if photo feeds are available
[Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypephotolibrary]

2.allowsEditing Default No
Whether to allow editing
Allow editing.
[Imagepicker Setallowsediting:yes];


3. Videomaximumduration
? Set the maximum video duration for the uiimagepicker. Default 10 minutes


4. + Availablemediatypesforsourcetype://Specify the type of media available for the source
Get media types supported in camera mode
nsarray* availablemediatypes = [Uiimagepickercontroller availablemediatypesforsourcetype: Uiimagepickercontrollersourcetypecamera];


5. SourceType
Set Uiimagepicker photo source type, by default there are 3 types.
Photo Source Type
 
 UIImagePickerControllerSourceTypeCamera             Camera
 UIImagePickerControllerSourceTypePhotoLibrary       Photo gallery (stored by sync, user cannot delete)
 UIImagePickerControllerSourceTypeSavedPhotosAlbum  saved photos (saved by photo or screenshot) User can delete)

6.UIImagePicker Use step:
?     checks whether the specified source is available. Issourcetypeavailable: Method.?      Check the available media (video or only pictures) Availablemediatypesforsourcetype: method.?      set Interface Media Properties MediaTypes property.?      display interface using PresentViewController:animated:completion: Method. The ipad is in popover form. You need to make sure that the sourcetype is valid. ?     The associated operation, remove the view. ??? If you want to create an image picker with a fully customizable interface to browse the pictures, use the classes in the Assets Library Framework reference. ("Media Capture and Access to Camera" in AV Foundation Programming Guide)??  ??


7. Set the source?
?    + Availablemediatypesforsourcetype://Specify the type of media available for the source?      + issourcetypeavailable://Specify if the source is available on the device? SourceType?? The source type needs to be indicated before running the related interface. Must be valid, or throw an exception. Picker has been shown to change this value, picker will change accordingly to adapt. Default uiimagepickercontrollersourcetypephotolibrary.??


8. Set the Picker property?
?      Allowsediting//Is it editable?      Delegate? MediaTypes?? Indicates the type of media that is displayed in picker. Apply Availablemediatypesforsourcetype before setting each type: Check it. An exception occurs if NULL or if the type in array is not available. Default Kuttypeimage, Only pictures can be displayed.??

?
9.video Selecting parameters
??      Videoquality///video capture when selecting the quality of the encoding. Only mediatypes contains Kuttypemovie valid.? Videomaximumduration//sec, video Maximum recording time, default 10 minutes. Valid only when MediaTypes contains Kuttypemovie.

??
10. Custom interface
??       showscameracontrols?? Indicates whether picker displays the default camera controls. The default is yes, set to No to hide the default controls to use a custom overlay view. (so you can implement multiple selections instead of choosing one picker dismiss). Only Uiimagepickercontrollersourcetypecamera source is valid, otherwise nsinvalidargumentexception exception.       cameraoverlayview?? Custom view that is used to display above picker. Valid only when the source is Uiimagepickercontrollersourcetypecamera. Other times use throws the Nsinvalidargumentexception exception.       cameraviewtransform?? Pre-animated. Affects only pre-images and is not valid for custom overlay view and default picker. Used only when the source of picker is Uiimagepickercontrollersourcetypecamera, Otherwise nsinvalidargumentexception exception.??


11. Select Media
?? –takepicture?? Use the camera to select a picture. Custom overlay can be multi-selected. There is already a picture being selected that is invalid for the call and must wait for delegate to receive Imagepickercontroller:didfinishpickingmediawithinfo: Message before it can be picked again.    Non-Uiimagepickercontrollersourcetypecamera sources can cause exceptions.??    –startvideocapture?? –stopvideocapture?? End the video selection, and then the system calls delegate's Imagepickercontroller:didfinishpickingmediawithinfo: method.

??
12. Setting up the camera
?    Cameradevice//Lens Used (default rear)?    + iscameradeviceavailable://Camera device is available.?      + Availablecapturemodesforcameradevice://Device available selection mode?      Cameracapturemode//Camera Capture mode?    Cameraflashmode//Flash mode (default auto)? + Isflashavailableforcameradevice://Is there a flash capability??


13.UIImagePickerControllerDelegate


Save the image using Uiimagewritetosavedphotosalbum,

Uisavevideoatpathtosavedphotosalbum Save the video. After 4.0 use WriteImageToSavedPhotosAlbum:metadata:completionBlock: Save metadata.??

-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info ?? Include the selected picture or a video URL as described in "Editing information Keys."?? If you set an editable property, picker will pre-display the selected media, and the edited and original will be saved in info.

–imagepickercontrollerdidcancel:? –imagepickercontroller:didfinishpickingimage:editinginfo://deprecated in IOS 3.0

?? NSString *const uiimagepickercontrollermediatype;//Media type?

NSString *const uiimagepickercontrolleroriginalimage;//Original unedited image

? NSString *const uiimagepickercontrollereditedimage;//edited image

? NSString *const uiimagepickercontrollercroprect;//Source image editable (valid?) Regional?

NSString *const uiimagepickercontrollermediaurl;//Video Path

? NSString *const uiimagepickercontrollerreferenceurl;//The URL of the original selection

? NSString *const uiimagepickercontrollermediametadata;//is valid only when using the camera and the image type. Contains the dictionary type that selects the image information?


Uiimagepickercontroller Small Example
Uiimagepickercontroller agents are required to abide by these two protocols. <uiimagepickercontrollerdelegate, Uinavigationcontrollerdelegate>

#pragma mark Select a photo
-(void) Selectphoto
{
1. First determine if the photo source is available
if ([Uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypephotolibrary]) {

0) Instantiating the controller
Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc]init];
1) Set Photo source
[Picker setsourcetype:uiimagepickercontrollersourcetypephotolibrary];

2) settings Allow modification
[Picker Setallowsediting:yes];
3) Set up the agent
[Picker setdelegate:self];
4) Display Controller
[Self Presentviewcontroller:picker animated:yes completion:nil];

} else {
NSLog (@ "photo source not available");
}

}

#pragma Mark-imagepicker Proxy method
-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info
{
UIImage *image = info[@ "Uiimagepickercontrollereditedimage"];
[_imagebutton setimage:image Forstate:uicontrolstatenormal];

Turn off photo Selector
[Self dismissviewcontrolleranimated:yes completion:nil];

Need to save photos to the application sandbox, as it relates to data storage, and is not interface-Independent
You can save images using multiple threads
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{

Save Image
1. Take image Path
Nsarray *docs = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *imagepath = [docs[0]stringbyappendingpathcomponent:@ "Abc.png"];

2. Convert to NSData Save
NSData *imagedata = uiimagepngrepresentation (image);
[ImageData Writetofile:imagepath Atomically:yes];
});
}


iOS Development UI Foundation Uiimagepickercontroller Properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.