Re-Add tabBarController's view into window and the device is in landscape mode
Posted
by user285553
on Stack Overflow
See other posts from Stack Overflow
or by user285553
Published on 2010-05-12T18:11:25Z
Indexed on
2010/05/12
18:14 UTC
Read the original article
Hit count: 253
uitabbarcontroller
|objective-c
Hello,
I have an app that is a tabBarController based app.
I have 4 tabs on it and one of these is for logging in/out in my app. The main ideea is that when I logout, I release the tabBarController (this will release the all 4 view controllers too - I have done this becuse I want to refersh all the views after logging out to look just like the first time).After this, I alloc it again and add the view controllers aagin,set the tabBarItem's titles,etc.This work ok.
The problem is when I am in landscape mode;my logout view is painted to fit the landscape area,but after disconnect(now I releasse and alloc again the tabbarController) the view is painted in portrait mode but my device is in lanscape.
After disconnected, I call the releaseOldTabView and the createNewTabView.After this tabBarController is in portrait insead of landscape.
-(void)releaseOldTabView:(BOOL)tabViewEnabled{
if(tabViewEnabled){
[tabBarController.view removeFromSuperview];
[tabBarController release];
}
}
-(void)createNewTabView{
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *oneArray = [[NSMutableArray alloc] init];
tabBarController.delegate = self;
LoginViewController *login= [[LoginViewController2 alloc] initWithNibName:@"LoginViewController" bundle:nil];
SecondViewController *secondController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *thirdController = [[ThirdViewController alloc] init];
FourthViewController *fourthController = [[FourthViewController alloc] init];
login.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Login" image:[UIImage imageNamed:@"connect.png"] tag:0];
secondController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"TabBar2" image:[UIImage imageNamed:@"tabBar2.png"] tag:1];
thirdController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"TabBar3" image:[UIImage imageNamed:@"tabBar3.png"] tag:2];
fourthController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"TabBar4" image:[UIImage imageNamed:@"tabBar4.png"] tag:3];
[oneArray addObject:login];
[oneArray addObject:secondController];
[oneArray addObject:thirdController];
[oneArray addObject:fourthController];
[tabBarController setViewControllers:oneArray];
//[tabBarController.view convertRect:tabBarController.view.frame toView:window];
[window addSubview:tabBarController.view];
[oneArray release];
[login release];
[secondController release];
[thirdController release];
[fourthController release];
}
After calling this method, the tabbar view is in portrait,but statusBar(the top bar which says the carrier name) is painted normally(landscape).
I also tried the [tabBarController.view convertRect:tabBarController.view.frame toView:window]; but without any succes.
Can anyone give a hand of help?
Thanks in advance,
Alex.
© Stack Overflow or respective owner