iphone - IOS UIImagePicker in a UIView subview -
i trying display uiimagepicker programatically generated uiview that's added subview of original view controller. image picker comes , camera functionality breaks , nothing navigates properly. how load image picker uiview , not uicontrolview?
code breaks:
- (void)captureimage:(id)sender { [[[uiactionsheet alloc] initwithtitle:nil delegate:self cancelbuttontitle:@"close" destructivebuttontitle:nil otherbuttontitles:@"take photo", @"camera roll", nil] showinview:self]; } //uiimagepicker specific methods -(void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex { switch (buttonindex) { case 0: [self takephoto]; break; case 1: [self fromcameraroll]; break; } } -(void)takephoto { if ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypecamera] == yes) { // create image picker controller uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init]; // set source camera imagepicker.sourcetype = uiimagepickercontrollersourcetypecamera; // delegate self imagepicker.delegate = self; // show image picker [self addsubview:imagepicker.view]; } } -(void)fromcameraroll { uiimagepickercontroller *imgpicker = [[uiimagepickercontroller alloc] init]; imgpicker.delegate = self; imgpicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; [self addsubview:imgpicker.view]; } -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { // access uncropped image info dictionary uiimage *image = [info objectforkey:@"uiimagepickercontrolleroriginalimage"]; //do image //add code pick images here , store them in preview [picker dismissmodalviewcontrolleranimated:no]; } -(void)imagepickercontrollerdidcancel:(uiimagepickercontroller *)picker { [picker dismissmodalviewcontrolleranimated:no]; }
uiimagepickercontroller view controller class, better present image picker parent view controller delegate call or overlay subview achieve goal.
uiimagepickercontroller *imgpicker = [[uiimagepickercontroller alloc] init]; imgpicker.delegate = self; imgpicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; customoverlayview *overlayview = [[customoverlayview alloc] init]; imgpicker.cameraoverlayview = overlayview; [self presentmodelviewcontroller:imgpicker animated:yes];
add delegate in overlay class dismiss camera picker controller view
[imgpicker dismissmodelviewcontrolleranimated:yes];
Comments
Post a Comment