ios - Custom camera works, live preview does not -


i'm attempting build custom camera app.

tasks:

  1. shows live image preview.
  2. allows tap anywhere on screen capture image.
  3. displays resulting image above live image preview.

currently works except task 1. view contains live image preview remains it's background color (or remains transparent when no background color selected), though camera operational , image displayed when screen tapped. ideas? i've referred previous discussion , think i'm covering bases: avfoundation camera preview layer not working

what missing?

-(void)viewwillappear:(bool)animated{     session = [[avcapturesession alloc] init];     [session setsessionpreset:avcapturesessionpresetphoto];      avcapturedevice *inputdevice = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo];     nserror *error;     avcapturedeviceinput *deviceinput = [avcapturedeviceinput deviceinputwithdevice:inputdevice error:&error];      if ([session canaddinput:deviceinput]) {         [session addinput:deviceinput];     }     avcapturevideopreviewlayer *previewlayer = [[avcapturevideopreviewlayer alloc] initwithsession:session];     [previewlayer setvideogravity:avlayervideogravityresizeaspectfill];      calayer *rootlayer = [[self view] layer];     [rootlayer setmaskstobounds:yes];     cgrect frame = self.frameforcapture.frame;      [previewlayer setframe:frame];      [rootlayer insertsublayer:previewlayer atindex:0];      stillimageoutput = [[avcapturestillimageoutput alloc] init];     nsdictionary *outputsettings = [[nsdictionary alloc] initwithobjectsandkeys:avvideocodecjpeg, avvideocodeckey, nil];     [stillimageoutput setoutputsettings:outputsettings];      [session addoutput:stillimageoutput];      [session startrunning];     //.... } 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -