views:

508

answers:

0

I am currently making a camera app for iPhone and I have a strange phenomenon that I can't figure out. I would appreciate some help understanding.

When recreating an overlay view for passing to UIImagePickerController, I have been successfully been able to create the view programmatically. What I haven't been able to do is create the view with/without controller in IB, load it and pass it to the overlay pointer successfully. If I do it via IB, the view is not opaque and obscures the view of the camera completely. I can not figure out why.

I was thinking that the normal view pointer might be assigned when loading from XIB and therefore overwrite the camera's view, but I have an example programmatically where view and overlayView are set equal in the controller class. Perhaps the load order is overwriting a pointer?

Help would be appreciated... kind regards.

This works fine...

    - (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]; 
}

This DOESN'T...

- (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];
}