简体   繁体   English

UIInterfaceOrientation问题

[英]UIInterfaceOrientation problem

My program is not supporting the UIInterfaceOrientation.我的程序不支持 UIInterfaceOrientation。 Program will not support the UIInterfaceOrientation after I add the UITabBarItem.Please give a solution.添加UITabBarItem后程序将不支持UIInterfaceOrientation。请给出解决方案。 Also I added the navigationController.我还添加了导航控制器。 Here is my code.这是我的代码。

-(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];
}

If you have UITabBarController, all the tabs should support your interface orientation.如果您有 UITabBarController,则所有选项卡都应支持您的界面方向。 So if you have 3 tabs and 2 of them support portrait and landscape, but the last one supports only portrait, you application will never turn to landscape.因此,如果您有 3 个选项卡,其中 2 个支持纵向和横向,但最后一个仅支持纵向,您的应用程序将永远不会转向横向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM