UITabbar 应用程序中的方向问题
我正在开发标签栏应用程序,其中我按以下方式调用导航控制器 问题是我无法定向到横向模式。谁能告诉我我做错了什么吗?
问候, 萨蒂什
-(IBAction)click
{
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:5];
UINavigationController *localNavigationContriller;
FavouritesViewController *master;
master = [[FavouritesViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:master];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[master release];
NeedViewController *need;
need = [[NeedViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:need];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[need release];
DontNeedViewController *dontneed;
dontneed = [[DontNeedViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:dontneed];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[dontneed release];
tabBarController.delegate=self;
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[[[UIApplication sharedApplication] keyWindow] addSubview:tabBarController.view];
}
I am working on tab bar application in which i called navigation controller on following way
The problem is i cannot able to oriented to Landscape mode. can anybody please say what i went wrong?
Regards,
sathish
-(IBAction)click
{
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:5];
UINavigationController *localNavigationContriller;
FavouritesViewController *master;
master = [[FavouritesViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:master];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[master release];
NeedViewController *need;
need = [[NeedViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:need];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[need release];
DontNeedViewController *dontneed;
dontneed = [[DontNeedViewController alloc] initWithTabBar];
localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:dontneed];
[localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[localControllersArray addObject:localNavigationContriller];
//[localNavigationContriller release];
[dontneed release];
tabBarController.delegate=self;
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[[[UIApplication sharedApplication] keyWindow] addSubview:tabBarController.view];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听着,伙计,你必须在所有选项卡栏中将 shouldrotate 函数重写为 YES,就像你的应用程序中有 3 个选项卡栏一样,转到相应的类以及
选项卡栏的所有相应类中...希望有所帮助,如果它确实为我祈祷......
Listen dude u you have to override the shouldrotate function to YES in all the tab bar , like you have 3 tab bar in your app , go to there respective class and
in all the respective class of the tab bar... hope that help , if it does pray for me ...
不可能更改 tabBar 中一个视图的方向而不更改另一个视图的方向。如果指定了 TabBar,则所有子视图(选项卡)必须具有相同的方向外观。您必须在每个 ViewController 和 TabBarController 中设置方向。
因此,只需将其添加到所有选项卡栏的主控制器中,
在您的情况下,要添加此代码的控制器是
FavoritesViewController,
NeedViewController &
DontNeedViewController
It's not possible to change the orientation for one view in a tabBar and not for another. If a TabBar is specified then all the subviews (tabs) must have the same orientation appearance. You must set the orientation in each ViewController and in the TabBarController.
So just add this in all the tabbar's main Controllers
In your Case those controllers where this code is to be added are
FavouritesViewController,
NeedViewController &
DontNeedViewController