I have this code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if( UIInterfaceOrientationIsLandscape(toInterfaceOrientation) )
{
[[NSBundle mainBundle] loadNibNamed:@"ChatViewController-landscape" owner:self options:nil];
}else {
[[NSBundle mainBundle] loadNibNamed:@"ChatViewController" owner:self options:nil];
}
}
I have set a breakpoint in if( UIInterfaceOrientationIsLandscape(toInterfaceOrientation) line. But the first time it doesn't enters that line of code. If I turn the phone, that time and subsecuent the method IS called. How can I make that method invoked the first time?
I think for the first time you will have to check the orientation on viewdidload and then load the nib file accordingly, you can create a single method that can be called from willRotateToInterfaceOrientation and viewDiD load for that
[[UIDevice currentDevice] orientation] this will give current orientation