0

我的程序不支持 UIInterfaceOrientation。添加UITabBarItem后程序将不支持UIInterfaceOrientation。请给出解决方案。我还添加了导航控制器。这是我的代码。

-(void) applicationDidFinishLaunching:(UIApplication *)application {
//I create my navigation Controller
    //UINavigationController *navigationController;
    //I create my TabBar controlelr
    tabBarController = [[UITabBarController alloc] init];
    // Icreate the array that will contain all the View controlelr
    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
    // I create the view controller attached to the first item in the TabBar

sivajitvViewController *firstViewController;
firstViewController = [[sivajitvViewController alloc]init];
navigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
//[navigationController.tabBarItem initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:1];
firstViewController.navigationItem.title=@"Gallery";
//viewController.tabBarItem.image = [UIImage imageNamed:@"natural.jpg"];
navigationController.tabBarItem.image = [UIImage imageNamed:@"Gallery.png"];
navigationController.tabBarItem.title = @"Gallery";
//navigationController.headerTitle = @"Some Title";


[localControllersArray addObject:navigationController];
[navigationController release];
[firstViewController release];

// I create the view controller attached to the second item in the TabBar

SecondViewController *secondViewController;
secondViewController = [[SecondViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
//[navigationController.tabBarItem initWithTabBarSystemItem:UITabBarSystemItemContacts tag:2];
navigationController.tabBarItem.image = [UIImage imageNamed:@"News.png"];
navigationController.tabBarItem.title = @"News";


[localControllersArray addObject:navigationController];
[navigationController release];
[secondViewController release];

// load up our tab bar controller with the view controllers
tabBarController.viewControllers = localControllersArray;

// release the array because the tab bar controller now has it
[localControllersArray release];

// add the tabBarController as a subview in the window
[window addSubview:tabBarController.view];

// need this last line to display the window (and tab bar controller)
[window makeKeyAndVisible];
}
4

1 回答 1

2

如果您有 UITabBarController,则所有选项卡都应支持您的界面方向。因此,如果您有 3 个选项卡,其中 2 个支持纵向和横向,但最后一个仅支持纵向,您的应用程序将永远不会转向横向。

于 2011-05-05T07:36:13.507 回答