仅制作 ios tabbar app portrait orientation 的 tab
make one tab of ios tabbar app portrait orientation only
我有一个标签栏 ios 应用程序。我只想将其中一个选项卡设为纵向。我怎么做?我已经在 How to force view controller orientation in iOS 8? and didn't help. I put that in view controller's .m code. This view controller has both a UIView and UITableView in it. pl see image below;
中尝试过解决方案
谢谢。
在你所有的视图控制器中写下这段代码:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll; //allow rotate landscape, portrait
}
并在您只需要纵向的 viewconroller 中编写此代码。
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown; // portrait only
}
或者你可以使用这个:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([self.window.rootViewController.presentedViewController isKindOfClass: [CompareViewController class]])
{
CompareViewController *compareController = (CompareViewController *) self.window.rootViewController.presentedViewController;
if (compareController.isPresented)
return UIInterfaceOrientationMaskLandscape;
else return UIInterfaceOrientationMaskPortrait;
}
else return UIInterfaceOrientationMaskPortrait;
}
尝试创建 UITabbarController 的扩展,然后覆盖扩展中的以下 2 个方法:
supportedInterfaceOrientations
shouldAutorotate
并且在这两种方法中:
只是验证,
if self.selectedIndex = 'particular index'
(标签索引,你想要纵向)和 return 相应地。
我有一个标签栏 ios 应用程序。我只想将其中一个选项卡设为纵向。我怎么做?我已经在 How to force view controller orientation in iOS 8? and didn't help. I put that in view controller's .m code. This view controller has both a UIView and UITableView in it. pl see image below;
谢谢。
在你所有的视图控制器中写下这段代码:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll; //allow rotate landscape, portrait
}
并在您只需要纵向的 viewconroller 中编写此代码。
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown; // portrait only
}
或者你可以使用这个:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([self.window.rootViewController.presentedViewController isKindOfClass: [CompareViewController class]])
{
CompareViewController *compareController = (CompareViewController *) self.window.rootViewController.presentedViewController;
if (compareController.isPresented)
return UIInterfaceOrientationMaskLandscape;
else return UIInterfaceOrientationMaskPortrait;
}
else return UIInterfaceOrientationMaskPortrait;
}
尝试创建 UITabbarController 的扩展,然后覆盖扩展中的以下 2 个方法:
supportedInterfaceOrientations
shouldAutorotate
并且在这两种方法中:
只是验证,
if self.selectedIndex = 'particular index'
(标签索引,你想要纵向)和 return 相应地。