- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 iOS 6 和 Xcode 4.5 在 Storyboard 中开发一个带有标签栏和一些导航 View Controller 的应用程序
通常应用程序应该支持所有界面方向,但我有两个 View 只应支持纵向模式。
所以我在 View Controller 中添加了以下代码:
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
我在 iOS 6 上开发的另一个没有 Storyboard和导航 View Controller 的应用程序可以工作,但她不行! :/
我希望有人能提供帮助,因为我发现了其他一些没有帮助的帖子...
德国致以最诚挚的问候
劳伦斯
编辑:
我也试过了——没用! :
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
最佳答案
据我所知,这个问题的出现是因为 UITabBarController 和 UINavigationController 正在为 -(BOOL)shouldAutorotate 和 -(NSUInteger)supportedInterfaceOrientations 返回它们自己的默认值。
一个解决方案是通过类别(或只是子类)扩展这两个类,以便从您自己的 View Controller 中这些方法的实现中返回适当的值。这对我有用(你可以把它放到你的 App Delegate 中):
@implementation UITabBarController(AutorotationFromSelectedView)
- (BOOL)shouldAutorotate {
if (self.selectedViewController) {
return [self.selectedViewController shouldAutorotate];
} else {
return YES;
}
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.selectedViewController) {
return [self.selectedViewController supportedInterfaceOrientations];
} else {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
@end
@implementation UINavigationController(AutorotationFromVisibleView)
- (BOOL)shouldAutorotate {
if (self.visibleViewController) {
return [self.visibleViewController shouldAutorotate];
} else {
return YES;
}
}
- (NSUInteger)supportedInterfaceOrientations {
if (self.visibleViewController) {
return [self.visibleViewController supportedInterfaceOrientations];
} else {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
@end
默认情况下,所有 View Controller 将继续自动旋转。在应该只支持纵向模式的两个 View Controller 中,实现以下内容:
-(BOOL)shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
关于ios6 - iOS 6 标签栏应用 : shouldAutorotate not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14896904/
我试图根据用户在我的应用程序中的位置来定义支持的方向,但我很难做到这一点。 到目前为止,我发现我应该使用 iOS6 中现在支持的supportedInterfaceOrientationsForWin
我对 iOS 中的自动旋转方法有点困惑。我正在为我的应用程序使用 Swift,它包含一个标签栏 Controller 和一个导航栏 Controller 。 问题是我希望所有 View Control
我知道如果 VC 有 navigationController 它应该包含一些类似 this 的东西.但是 swift 呢?如何使用navigationController在VC中调用shouldAu
我正在使用 Swift4 使用 Xcode9 开发一个应用程序,它最初仅适用于 iPad,但现在也需要在手机上运行。我需要将手机锁定为纵向,而 iPad 保持纵向/横向。 在使用 shouldauto
我正在制作一款仅在播放视频时支持横向播放的应用。否则,所有场景仅支持纵向。我已经在项目设置中检查了纵向、左右横向。我在 ViewControllers 中编写了以下代码,我想将其限制为仅纵向。 ove
我有一个 UIViewController 详细 View ,它是从 UINavigationController 中的 UITableView 推送的。在 UIViewController 中,我添
我的应用程序(iPad;iOS 6)是仅横向应用程序,但是当我尝试使用 UIPopoverController 来显示照片库时,它会抛出此错误:支持的方向与应用程序没有共同的方向,并且 shouldA
我的应用只有横向模式,使用这段代码我可以拍照 @IBAction func shootPhoto(sender: UIBarButtonItem){ if UIImagePickerContr
我有一个非常烦人的问题,我已经为此奋斗了几个小时。我有一个只能纵向运行的应用程序,但当我播放视频时,我希望它能横向播放。 据我所知,解决这个问题的方法是更改 Info.plist 以允许横向、横向
我的应用中有一些 View 不想支持方向。在 didFinishLaunchingWithOptions 我添加导航: ... UINavigationController *nav = [[UINa
这个问题在这里已经有了答案: Supported orientations has no common orientation with the application, and shouldAut
我知道这个问题之前在这里被问过 iOS 6 shouldAutorotate: is NOT being called .但我的情况有点不同。 最初,在应用程序启动时,我加载了一个 viewContr
我有一个 UINavigationController 和一个 UIViewController (VC1) 推到它上面。 VC1 包含一个collectionView。当用户点击一个单元格时,一个子
我的应用使用了多个库。基本上 KYDrawerController .我希望我的应用程序仅使用 potrait 方向,但对于一个 ViewControllar,我需要横向和 Potrait。 我在互联
我正在使用 iOS 6 和 Xcode 4.5 在 Storyboard 中开发一个带有标签栏和一些导航 View Controller 的应用程序 通常应用程序应该支持所有界面方向,但我有两个 Vi
即使我将 shouldAutoRotate 设置为 false,我也有一个正在旋转的 View (InfoVC)。这是打开 View 的代码(在模式内) - (IBAction)presentInfo
如何设置指定的页面旋转而不使其自动旋转?我发现只有当var shouldAutorotate返回yes时屏幕才能旋转,但我不想自动旋转,我想自己控制旋转的时刻 最佳答案 swift 4+: 使用以下代
我的第一个 View Controller 是 LoginViewController。我正在尝试支持 iOS 6 上的自动旋转管理。 我已经实现了 shouldAutorotate 而不是 shou
我有一个由单个 View Controller 组成的简单应用程序。我从 Xcode 7 GM 单 View 应用程序模板开始,但随后删除了主 Storyboard,并像这样设置我的 View Con
我发现 7.1 和 8 之间的 UIViewController shouldAutorotate 方法有一个小的行为变化。苹果View Controller Programming Guide指出在
我是一名优秀的程序员,十分优秀!