0

I've created a new "Tab Bar project" with the new Xcode 4.2. The "new" way to work with UITabBar is different: Xcode doesn't create a xib file (with the UITabBarController), but it does everything via code. Ok, let's do it.

So my code in didFinishLaunchingWithOptions is this:

UIViewController *viewController1, *viewController2, *viewController3;
UINavigationController *nav1, *nav2, *nav3;

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

   viewController1 = [[gemboy_iphone alloc] initWithNibName:@"vc1" bundle:nil];
   viewController2 = [[concerti_iphone alloc] initWithNibName:@"vc2" bundle:nil];
   viewController3 = [[discografia_iphone alloc] initWithNibName:@"vc3" bundle:nil];

   nav1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
   nav2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
   nav3 = [[UINavigationController alloc] initWithRootViewController:viewController3];

}
else {
  //same thing for the iPad version
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nav3, nil];
self.window.rootViewController = self.tabBarController;
[self.window addSubview:self.splash.view];
[self.window makeKeyAndVisible];
return YES;

And it works.

My three .m files vc1.m, vc2.m and vc3.m (and also my iPad UIViewControllers) has this method

- (BOOL)shouldAutorotate {

  return YES;
}

The problem is that when I rotate the iPhone, it's not rotating.

Any one please tell me where i done mistake and any thing wrong?

sreenivas
  • 399
  • 2
  • 5
  • 20

1 Answers1

0

You should subclass the uitabbarcontroller and implemetn

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskAll;
}   
Gad
  • 21
  • 4