UIView cameraOverlayView in Augmented Reality starts in portrait mode
<p>I'm doing a bit of AR work here and one of the biggest problem right now is one of my UIView will not respond to any frame settings I make to it.</p>

<p>The code is very similar to this. I've made a few major changes to incorporate into my project:</p>

<p>nurse.site11.com/JaredCrawford-iWVU-632a9a0/Libraries/ARKit/AugmentedRealityController.m</p>

<p>"displayView" is used as a custom UIView that is passed to UIImagePickerController's setCameraOverlayView: method.</p>

<p>Now in the initWithViewController method of that AugmentedRealityController.m file, I have tried setting the displayView = [[UIView alloc] initWithFrame:CGRectMakeFrame(0, 0, 480, 320)];</p>

<p>The problem is, even if I set it to displayView = [[UIView alloc] initWithFrame:CGRectMakeFrame(0, 0, 100, 100)]; the view still remains full screen 320 x 480 BUT only for the first time the Augmented Reality view appeared. Subsequent times that the AR view appears, the code works.</p>

<p>I am not sure what the heck is going on and why setting the frame of the displayView not affecting the view at all FOR THE FIRST TIME it is shown.</p>

<p>I'm hoping someone else has experienced this problem before and possibly solved it.</p>

<p>This is my code:</p>

<pre><code>- (id)initWithViewController:(UIViewController *)vc
{
    coordinates     = [[NSMutableArray alloc] init];
    coordinateViews = [[NSMutableArray alloc] init];
    latestHeading   = -1.0f;
    debugView       = nil;

    [self setRootViewController: vc];

    [self setDebugMode:NO];
    [self setMaximumScaleDistance: 0.0];
    [self setMinimumScaleFactor: 1.0];
    [self setScaleViewsBasedOnDistance: YES];
    [self setRotateViewsBasedOnPerspective: YES];
    [self setMaximumRotationAngle: M_PI / 6.0];

    //CGRect screenRect = [[UIScreen mainScreen] bounds];

    NSLog(@"inside initWithViewController");    

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

    if(orientation == UIDeviceOrientationPortrait)
    {
        NSLog(@"Orientation portrait");
    }
    else if(orientation == UIDeviceOrientationLandscapeRight)
    {
        NSLog(@"orientation right");
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
        [self setCurrentOrientation:UIDeviceOrientationLandscapeRight];
    }
    else if(orientation == UIDeviceOrientationPortraitUpsideDown)
    {
        NSLog(@"orientation upsidedown");             
    }
    else if(orientation == UIDeviceOrientationLandscapeLeft){
        NSLog(@"orientation left");
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
        [self setCurrentOrientation:UIDeviceOrientationLandscapeLeft];
    }

    //[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];


    //NSLog(@"In AR view, device orientation = %@", [[UIDevice currentDevice] orientation]);

    //[self setDisplayView: [[UIView alloc] initWithFrame: screenRect]];
    //[self setCurrentOrientation:UIDeviceOrientationLandscapeRight];

    displayView = [[UIView alloc] initWithFrame:CGRectMake(-80, 80, 480, 320)]; 

    [displayView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:0.5]];

    NSLog(@"displayView x = %f", displayView.frame.origin.x);
    NSLog(@"displayView y = %f", displayView.frame.origin.y);
    NSLog(@"displayView width = %f", displayView.frame.size.width);
    NSLog(@"displayView height = %f", displayView.frame.size.height);

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

    [[self rootViewController] setView:displayView];
    //[[self rootViewController] setView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]];

    //[[rootViewController view] setBackgroundColor:[UIColor blueColor]];

    CLLocation *newCenter = [[CLLocation alloc] initWithLatitude:37.41711 longitude:-122.02528];
    [self setCenterLocation: newCenter];
    [newCenter release];

    [self startListening];

    [self deviceOrientationUpdate];

    startLocation = nil;
    i = 0;
    objImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
    //[objImageView setBackgroundColor:[UIColor blueColor]];

    blnHasRotated = NO;

    return self;
}
</code></pre>

<p>The full code can be seen here: pastebin.com/g0eXJaPq</p>
