views:

21

answers:

1

Hi all,

I have a tabBarViewController and when in tab 0 the user is able to turn the device horizontally and landscapeViewController is displayed. In the landscape view controller I need to be able to load different full screen views, using buttons, depending on what the user wishes to see. It works to a point but then gets mixed up. Basically when the user 1st rotates the view is loaded correctly but then when the viewController tries to load the 2nd landscape view it doesnt reposition the elements in this view, only the status bar? If I then rotate to the other landscape orietnation it sorts itself out? Does anyone know what Im doing wrong?

Here is some of my code

-(void)viewWillAppear:(BOOL)animated {
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}

-(void)detectOrientation {
   if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) 
      [delegate landscapeViewController:self didRotateBack:YES]; 

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

-(IBAction)showSecondLandscapeView {
    self.view = secondLandscapeView;
}

Many thanks

Jules

EDIT: I should also mention that the landscapeViewController is being presented modally, not sure if this makes any difference though.

A: 

Ok, turns out if I change self.view = secondView to [self.view addSubview:secondView] it works.

Jules