views:

63

answers:

1

Hi, How can i rotate tabbarcontroller in landscape mode when i am having XIB file(tab bar controller) in portait.i wrote the follwing in appdelegate

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } , but it wont be rotated any help please?
A: 

AS i remember, you cannot rotate the SDK's UITabBar controller. You chold make your own tabbar, inherint it from UITabBar and there return YES in shouldAutoRotate method.

#import <UIKit/UIKit.h>    
  @interface MainTabBarController : UITabBarController{
  }    
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

this is an .h file

#import "MainTabBarController.h"
@implementation MainTabBarController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
} 
@end

You just have to change class of your tabbar from UITabBarController to MainTabBarController

Morion
any tutorial please..?
Mikhail Naimy
Oh, i have no mac with XCode right now nerby. You can try to inherit your own TabBar from UITabBar (in your .h file @interface MyTabBar : UITabBar). You can implement noting exept your shouldAutorotate... method in .m file. Correct example I can post only on monday.
Morion
will you give correct example?
Mikhail Naimy
Ok, I'll post an example in a few hours.
Morion
you did not post correct example?
Mikhail Naimy