How can I make the Camera View to open faster?

2019-08-05 05:48发布

问题:

I use the iOS CameraViewController TGCameraViewController. It works great. My problem is that the camera view (i.e., when you run the example and hit the "capture image" button) view takes a very long time to be initialized and ready for the user. The AVFoundation is used.

Is there a way to make the camera view appear much faster in the state where the user can capture a photo?

Edit:

I initialized the ViewController right before I need it. The controller is called by a Cordova method call as follows:

-(void) openCamera:(CDVInvokedUrlCommand *)command {

  TGCameraNavigationController *navigationController = [TGCameraNavigationController  newWithCameraDelegate:self];    
  UIViewController *rootVC = [[UIApplication sharedApplication] delegate] window]  rootViewController];
  [rootVC presentViewController:navigationController animated:YES completion:nil];

}

Edit:

Here is what I did:

// Cordova command method
-(void) init:(CDVInvokedUrlCommand *)command {

    [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:[NSNumber numberWithBool:YES]];

    _navigationController = [TGCameraNavigationController newWithCameraDelegate:self];
    _rootVC = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
}

// Cordova command method
-(void) openCamera:(CDVInvokedUrlCommand *)command {

    [_rootVC presentViewController: _navigationController animated:YES completion:nil];
}

I set up a part of the ViewController in an init method which is called only once when the app starts. Then when the user clicks on the take photo button in call openCamera. The problem is that this does not speed up the launch.

I tried the sample app from TGCameraViewController on iPhone5 and it takes a bit longer than the native camera app. This is exactly the problem I want the sample app to be as fast as the native camera app.

Is there a better way to speed up the launch of the camera?