Download OverlayView from XIB -vs- programmatically for use with UIImagePickerController

I am currently making an iPhone app for iPhone, and I have a strange phenomenon that I cannot understand. I would appreciate help in understanding.

When I recreated the overlay view to go to the UIImagePickerController, I was able to successfully create the view programmatically. What I could not do was create a view with / without a controller in IB, load it and successfully pass it to the overlay pointer. If I do this through IB, the view is not opaque and completely obscures the camera view. I can’t understand why.

I thought that a normal pointer viewcould be assigned when loading from XIB and therefore overwrite the camera view, but I have an example programmatically where view and overlayView are set equal in the controller class. Perhaps the boot order overwrites the pointer?

Help would be appreciated ... kindly.

This works great ...

    - (void)applicationDidFinishLaunching:(UIApplication *)application {

    // dislodge the MainView from the MainViewController
    //
    MainViewController *aController = [[MainViewController alloc] init]; //WithNibName:@"MainView" bundle:nil];

    aController.sourceType= UIImagePickerControllerSourceTypeCamera;
    aController.delegate= aController;

    aController.showsCameraControls= NO;

    // Programmatically load the MainView from the Nib and assign it as the OverlayView instead
    //
    NSArray* nibViews= [[NSBundle mainBundle] loadNibNamed:@"MainView" owner:aController options:nil];
    UIView* uiView= [nibViews objectAtIndex:0];
    uiView.opaque= NO;
    uiView.backgroundColor= [UIColor clearColor];
    aController.cameraOverlayView= uiView;

    self.mainViewController = aController;
    [aController release];

    mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;

    [window addSubview:[mainViewController view]];
    [window makeKeyAndVisible]; 
}

Is not...

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    // dislodge the MainView from the MainViewController
    //
    MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];

    aController.sourceType= UIImagePickerControllerSourceTypeCamera;
    aController.delegate= aController;

    aController.showsCameraControls= NO;
    aController.cameraOverlayView= aController.view;

    self.mainViewController = aController;
    [aController release];

    mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;

    [window addSubview:[mainViewController view]];
    [window makeKeyAndVisible];
}
+3
source share

Source: https://habr.com/ru/post/1737937/


All Articles