ios - UIWebView screen taps in area cease to work after showing then hiding a UIView overlay -


i have been working on app features full screen uiwebview contains html based application. features working qr code scan using native bridge between js , native obj-c code. tapping button launches uiview half size of overall display, overlay, inside see video feed , when qr code detected passes code , uiview closed. works treat.

however uiwebview suffers odd issue, elements have been underneath uiview become untappable. it's if there ghost of uiview still present.

any ideas why occurring?

- (void)handlecall:(nsstring*)functionname callbackid:(int)callbackid args:(nsarray*)args {     if ([functionname isequaltostring:@"setbackgroundcolor"]) {         ....... snip ........ } else if ([functionname isequaltostring:@"scanqrcode"]) {      _viewpreview = [[uiview alloc] initwithframe:cgrectmake(256, 192, 512, 384)];      [self addsubview:self.viewpreview];     [self bringsubviewtofront:_viewpreview];      _capturesession = nil;      if (!_isreading) {       if ([self startreading]) {         nslog(@"read barcode: %@", @"started");       }     }     else{       [self stopreading];        [_viewpreview removefromsuperview];       [_viewpreview release];       }      _isreading = !_isreading;   }   else   {     nslog(@"unimplemented method '%@'",functionname);    [unireader requestswipe];    [self returnresult:callbackid args:nil];     } }  - (bool)startreading {   nserror *error;    avcapturedevice *capturedevice = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo];    avcapturedeviceinput *input = [avcapturedeviceinput deviceinputwithdevice:capturedevice error:&error];    if (!input) {     nslog(@"%@", [error localizeddescription]);     return no;   }    _capturesession = [[avcapturesession alloc] init];   [_capturesession addinput:input];    avcapturemetadataoutput *capturemetadataoutput = [[avcapturemetadataoutput alloc] init];   [_capturesession addoutput:capturemetadataoutput];    dispatch_queue_t dispatchqueue;   dispatchqueue = dispatch_queue_create("myqueue", null);   [capturemetadataoutput setmetadataobjectsdelegate:self queue:dispatchqueue];   [capturemetadataoutput setmetadataobjecttypes:[nsarray arraywithobject:avmetadataobjecttypeqrcode]];    _videopreviewlayer = [[avcapturevideopreviewlayer alloc]    initwithsession:_capturesession];  [_videopreviewlayer setvideogravity:avlayervideogravityresizeaspectfill];  [_videopreviewlayer setframe:_viewpreview.layer.bounds];  [_viewpreview.layer addsublayer:_videopreviewlayer];  // since app landscape only, necessary rotate preview view match  [_videopreviewlayer.connection setvideoorientation:avcapturevideoorientationlandscapeleft];  // start video capture.  [_capturesession startrunning];   return yes; 

}

 -(void)stopreading{  [_capturesession stoprunning];  _capturesession = nil;     nslog(@"read barcode: %@", @"stop scanning");   [_videopreviewlayer removefromsuperlayer]; 

}

   -(void)captureoutput:(avcaptureoutput *)captureoutput    didoutputmetadataobjects:(nsarray *)metadataobjects fromconnection:  (avcaptureconnection *)connection{   // check if metadataobjects array not nil , contains @ least 1 object.  if (metadataobjects != nil && [metadataobjects count] > 0) {  // metadata object.  avmetadatamachinereadablecodeobject *metadataobj = [metadataobjects objectatindex:0];  nsstring *barcodestring = metadataobj.stringvalue;  nslog(@"detected qr: %@", barcodestring);  nsstring *javascript = [nsstring stringwithformat:@"setqr('%@')", barcodestring];  if ([[metadataobj type] isequaltostring:avmetadataobjecttypeqrcode]) {   // if found metadata equal qr code metadata update status label's text,   // stop reading , change bar button item's title , flag's value.   // done on main thread.    [self performselectoronmainthread:@selector(stopreading) withobject:nil waituntildone:no];    _isreading = no;   [self performselectoronmainthread:@selector(stringbyevaluatingjavascriptfromstring:) withobject:javascript waituntildone:no]; } 

} }

@end

is scanqrcode called twice: once add , once remove overlay? if add new overlay view @ start. stopreading remove running video superview (the original overlay) remove latest overlay screen. leave original overlay window no content issue?


Comments

Popular posts from this blog

SQL php on different pages to Insert (mysqli) -

php - How can an email be returned from Stripe Checkout? -

sql - Partition elimination in Greenplum -