-(Ibaction) Actionphoto: (ID) Sender//----------------------------------------------------------------------------------------------------------- --------------------------------------{presentphotolibrary (self, YES);}#pragmaMark-uiimagepickercontrollerdelegate//----------------------------------------------------------------------------------------------------------- --------------------------------------- (void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) Info//----------------------------------------------------------------------------------------------------------- --------------------------------------{..................}
//----------------------------------------------------------------------------------------------------------- --------------------------------------BOOL Presentphotolibrary (IDtarget, BOOL canedit)//----------------------------------------------------------------------------------------------------------- --------------------------------------{ if([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypephotolibrary] = =NO&& [Uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypesavedphotosalbum] = = NO ))returnNO; //----------------------------------------------------------------------------------------------------------- ----------------------------------NSString *type = (NSString *) Kuttypeimage; Uiimagepickercontroller*imagepicker =[[Uiimagepickercontroller alloc] init]; //----------------------------------------------------------------------------------------------------------- ---------------------------------- if([Uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypephotolibrary]&&[[Uiimagepickercontroller availablemediatypesforsourcetype:uiimagepickercontrollersourcetypephotolibrary] Containsobject:type]) {Imagepicker.sourcetype=uiimagepickercontrollersourcetypephotolibrary; Imagepicker.mediatypes=[Nsarray Arraywithobject:type]; } Else if([Uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypesavedphotosalbum]&&[[Uiimagepickercontroller Availablemediatypesforsourcetype: Uiimagepickercontrollersourcetypesavedphotosalbum] Containsobject:type]) {Imagepicker.sourcetype=Uiimagepickercontrollersourcetypesavedphotosalbum; Imagepicker.mediatypes=[Nsarray Arraywithobject:type]; } Else returnNO; //----------------------------------------------------------------------------------------------------------- ----------------------------------Imagepicker.allowsediting =CanEdit; Imagepicker.Delegate=Target; [Target Presentviewcontroller:imagepicker Animated:yes Completion:nil]; //----------------------------------------------------------------------------------------------------------- ---------------------------------- returnYES;}
Open Album Alternative notation