Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6922619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:25:47+00:00 2026-05-27T10:25:47+00:00

In my phonegap-based iPhone web-app I implemented a plugin that uses AVCaptureVideoPreviewLayer to take

  • 0

In my phonegap-based iPhone web-app I implemented a plugin that uses AVCaptureVideoPreviewLayer to take a photo. To do so, when the plugins’ startCamera method is called, I set the background of the webview to be transparent and insert the video capture layer below the layer of the webview. This works as expected (most of the time).

But for some strange reason, when I execute startCamera for the first time (after a fresh app start), the video layer isn’t visible. Instead, the webview displays a white background, although the background color is set to clearColor. For all subsequent executions, the video layer is visible.

This is what I’m doing to show the camera:

AVCaptureSession * session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetHigh;

AVCaptureVideoPreviewLayer * videoLayer = 
  [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
videoLayer.frame = self.webView.bounds; 

CALayer *webViewLayer = self.webView.layer;    
[webViewLayer.superlayer insertSublayer:videoLayer below:webViewLayer];    

// ... session setup excluded
[session startRunning];    

[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];

In stopCamera() I do the following:

if (session) {
    [session stopRunning];
}
[self.webView setBackgroundColor:[UIColor blackColor]];
[self.webView setOpaque:NO];
if (videoLayer != nil) {
    [videoLayer removeFromSuperlayer];
}

Any ideas why the camera layer isn’t visible for the first time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:25:48+00:00Added an answer on May 27, 2026 at 10:25 am

    Solved it: The problem was, that setting the opacity flag of the webview to NO didn’t have any effect when it was done in startCamera(). To fix it, I set the opacity of the webview earlier – just when it was created. A webview with no opacity doesn’t mean that it is transparent though – you also need to set the background color to [UIColor clearColor] (this is what is done in startCamera(); in stopCamera() the background color is set back to [UIColor blackColor]).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Rails app which communicates with a PhoneGap-based iPhone app. We are
My native iphone app, developed with phonegap with jquery (so its browser based), can
My phonegap based application which uses JQTouch and JQuery works fine on iPhone, Android,
I'm building an Android application that's based around an enhanced WebView (based on PhoneGap).
I've read about phonegap which enables users to write web-based apps for android and
We are building a PhoneGap app (both for iOS and Android) that has a
I'm having troubles to find the SQLite databases that Phonegap creates on iPhone and
So, I am working on this phonegap-based app. Most of our code is checked
I am trying to implement a Codeigniter based app on Android via phonegap, all
I wrote a phonegap / jQuery mobile app which runs fun in the iphone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.