ios - UIImagePickercontroller not saving without use button -
i'm using uiimagepickercontroller take picuture , save photo gallery. when launch picker has button photo take , cancel after taking photo shows 2 button retake & use, if use, use button image saving photo album after saving can't go previous page or close picker.
-(void)takepicture:(id)sender{ // create image picker controller uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init]; // set source camera imagepicker.sourcetype = uiimagepickercontrollersourcetypecamera; // delegate self imagepicker.delegate = self; // show image picker [self presentmodalviewcontroller:imagepicker animated:yes]; // [self performselector:@selector(ontimer_loadpicture:) withobject:nil afterdelay:0.5]; } - (void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { // access uncropped image info dictionary uiimage *image = [info objectforkey:@"uiimagepickercontrolleroriginalimage"]; // save image uiimagewritetosavedphotosalbum(image, self, @selector(image:didfinishsavingwitherror:contextinfo:), nil); // uiimagewritetosavedphotosalbum(image, nil, nil, nil); [picker release]; } - (void)imagepickercontrollerdidcancel:(uiimagepickercontroller *)picker { [self dismissmodalviewcontrolleranimated:yes]; } - (void)image:(uiimage *)image didfinishsavingwitherror:(nserror *)error contextinfo:(void *)contextinfo { uialertview *alert; // unable save image if (error) alert = [[uialertview alloc] initwithtitle:@"error" message:@"unable save image photo album." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; else // alert = [[uialertview alloc] initwithtitle:@"success" message:@"image saved photo album." delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; [alert release]; [self performselector:@selector(ontimer_loadpicture:) withobject:nil afterdelay:0.5]; }
just dismiss view controller. ,update didfinishpickingmediawithinfo method
- (void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { // access uncropped image info dictionary uiimage *image = [info objectforkey:@"uiimagepickercontrolleroriginalimage"]; // save image uiimagewritetosavedphotosalbum(image, self, @selector(image:didfinishsavingwitherror:contextinfo:), nil); // uiimagewritetosavedphotosalbum(image, nil, nil, nil); [picker dismissviewcontrolleranimated:yes completion:null]; }
Comments
Post a Comment