I am new to iphone development..
am creating one small application where two viewcontrollers like
- loginController
- updateController
For apply orientation i created two views for each controller like
for
first controller these are ‘landscapeLoginView’ & ‘portraitLoginView’
& for second these are ‘landscapeUpdateView’ & ‘portraitUpdateView’
I define ‘isLogin’ variable in MainControllerDelegate file,
Code for orientation is as given below,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
TestAppDelegate *testDelegate = (TestAppDelegate *)[[UIApplication sharedApplication] delegate];
if(testDelegate.isLogin) {
UpdateController *updateController = [[UpdateController alloc] initWithNibName:@"UpdateController" bundle:nil];
[self.view addSubview:updateController.view];
[updateController release];
return YES;
} else
{
if(UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
self.view = self.portrait;
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
self.view = self.landscape;
}
return YES;
}
}
This will load the respected orientation after clicking on ‘Login’ button.
Everything work fine for ‘LoginController’ like button events & all.
but,
when i entered on ‘UpdateConroller’ and update text from TextView by clicking ‘Update’button, it’s updated for ‘PortraitView’ not for ‘LandscapeView’.
In Interface Builder i set ‘PortraitView’ to ‘view’.
How can i achive same functionality for ‘LandscapeView’? Am i doing right?
You really should use the ability of UIView autoresizingMask… So you will have only one UIViewController for both portrait and landscape mode
It will be faster, and less of the headache to use.