IOS8 UIImagePickerController in custom keyboard extension

I am experimenting with trying to have a built-in camera inside an iOS8 custom keyboard extension with full access enabled. Everything works as I would expect, except that the inline view of the UIImagePickerController is always black, except for the overlay controls. Pop-up displays "this app would like to access your camera" and access is definitely (triple checked).

Xcode [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]

returns true and displays the UIImagePickerController aside from the camera itself correctly (for example, camera overlay controls).

The only error / warning message I get from Xcode is this:

A snapshot that has not been displayed results in a blank snapshot. Make sure your view has been viewed at least once before the snapshot or snapshot after screen updates.

I tried adding timeouts to camera initialization as several other stackoverflow threads suggested, but nothing fixes this warning or black screen issue.

- (void)viewDidAppear:(BOOL)animated
{
    [self performSelector:@selector(loadCamera) withObject:nil afterDelay:0.3];
}

- (void)loadCamera
{
self._picker = [[UIImagePickerController alloc] init];

self._picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self._picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self._picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self._picker.allowsEditing = NO;
self._picker.showsCameraControls = YES;
self._picker.view.userInteractionEnabled = YES;

self._picker.delegate = self;

self._picker.view.frame = self.view.bounds;
[self.view addSubview:self._picker.view];
[self._picker didMoveToParentViewController:self];
}

      

I also tried to replace the last 3 lines with the following result:

[self presentViewController:self._picker animated:YES completion:^{
    NSLog(@"completed");
}];

      

Does anyone know if it is possible to inject a UIImagePickerController into an iOS8 custom keyboard extension, and if so, what might I be doing wrong?

+3


source to share


1 answer


Apparently, camera or microphone access is not possible in extensions.



See duplicate stream here with reference to Apple doc: iOS Custom Keyboard - Camera Not Working .

+2


source







All Articles