Reputation: 1335
I created a simple xib file with a UIView and a UILabel in the middle of the view. I then set the owner of the xib to be the ViewController that will be using it. I created an outlet from the UIView to my ViewController and did the following:
imagePicker.cameraOverlayView = self.cameraOverlay;
The problem I am having is that it is not appearing when I open the camera. If I create the UIView programmatically it works, but it doesn't seem to work if I use a xib file.
Below is the code where I set the overlay, and camera:
- (IBAction)takeVideo:(id)sender {
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
NSArray *availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
if ([availableTypes containsObject:(__bridge NSString *)kUTTypeMovie]) {
[imagePicker setMediaTypes:@[(__bridge NSString *)kUTTypeMovie]];
}
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.cameraOverlayView = self.cameraOverlay;
[self presentViewController:imagePicker animated:YES completion:nil];
}
The camerOverlay is (strong, nonatomic)
Upvotes: 0
Views: 227
Reputation: 769
Have you loaded the nib in code?
self.cameraOverlay = [[[NSBundle mainBundle] loadNibNamed:@"YourNibNameHere" owner:self options:nil] objectAtIndex:0];
Place this in your viewDidLoad
method.
Upvotes: 1