- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好!这是场景。
从导航 Controller (并且不存在选项卡栏 - 它在之前的 View Controller 推送中隐藏)开始,我初始化一个新的 View Controller 并将其推送到导航 Controller 堆栈上。这个新的 VC 包含一个孤独的 UIView,我以编程方式向其中添加一个具有相同框架的 UIScrollView。 (我想避免 UIView,但这是我可以将 self.view 分配给某些东西的唯一方法。我怀疑转换 UIScrollView viewDidLoad 中使用 到 UIView。)
现在我们有了一个导航栏和一个 ScrollView 。我已经将其设置为滚动浏览一些图像(我知道,这是很大的惊喜!),效果很好。现在我希望它支持自动旋转。所以我在 VC 中回复如下:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
编译并运行。啊啊……没什么。显然我做错了什么。
现在,我已经阅读了有关 UINavigationController and autorotation 的帖子,我隐隐怀疑我的做法是错误的,并且让事情变得比必要的更加复杂。
必须有一种更好的方法来呈现支持自动旋转的UIScrollView。也许导航 Controller 妨碍了,但我不知道如何解决它。
理想情况下,我想要不显示任何导航栏的东西。相反,我们有一个从顶部显示/隐藏的工具栏/状态栏(就像您在播放视频时看到的那样)。如果导航栏必须保留 - 或者如果我在播放视频时看到的导航栏与工具栏相比确实是一个高度较短的导航栏,但是我能让它旋转吗?问题是,我只希望它在查看像素时以这种特定模式旋转。其他时间都不会。
我敢尝试使用模态 VC 吗? (是的 - 不,这也不对。而且它还有一个导航栏。)
最佳答案
您可以通过创建 UITabBarController 类别来解决此问题,而无需子类化。
这是处理我的情况的类别实现,其中我有与我的选项卡关联的匿名 UINavigationController 和作为 UINavigationController 的 Root View Controller 的自定义 UIViewController 子类:
@implementation UITabBarController (Rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *rootController = [((UINavigationController *)self.selectedViewController).viewControllers objectAtIndex:0];
return [rootController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
@end
我在 UINavigationController 上还有一个类别,默认返回 YES。因此,默认行为是启用旋转,并且对于我希望禁用旋转的 Controller 和方向,我可以从 shouldAutorotateToInterfaceOrientation:interfaceOrientation 返回 NO。
关于iphone - UINavigationController 和 UITabBarController 中的选择性自动旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1196758/
根据这个: Selectivity is the value between 0 and 1, and it is the fraction of rows returned after applyi
我想知道C是否允许设置选择性#define。这就是我所说的选择性:如果我定义了一个结构: typedef struct mystruct{ int (*pointer_function)(struc
我正在尝试替换 pi与 math.pi使用以下 Python 函数。 def cleanup(x): return x.replace("pi", "math.pi") 我有以下字符串: a =
有没有一种方法可以只对类型声明可用的代码执行流程检查? 有一种方法可以启用每个文件的检查( header 中的 //@flow),但是一旦设置,代码的所有部分都需要类型声明(否则会记录错误,如“108
我在 openGL (openGl 1.1 win32) 中绘制了一个场景。 我使用 glClipPlane 隐藏前景对象以允许用户查看/编辑距离部分。选择是在 native 完成的,无需使用 ope
我正在开发允许第三方上传 HTML 片段的服务。在其中一些片段中,可能有指向 CSS 文件或内联 CSS 的链接。该服务有自己的 CSS 文件。 除了 iFrame 之外,还有什么方法可以让我指示特定
假设我有下面列出的用于通过 Web 服务将数据传递给客户端的类(类已简化): public class Customer { public int CustomerId { get; set;
我肯定有一个相当普遍的文档需求...... 我正在实现一个相当大的 Java 库代码库,除其他外,它包含各种类,这些类旨在在适当的抽象级别上公开给调用者/实现者。同时,代码库当然包含库的用户在使用 A
我有我的小 program.jar,它使用了巨大的 library.jar 的一小部分。 是否有一种工具可以将几个 jar 重新打包成一个,以便它可以独立运行并且尽可能小? 更新:大小很重要。 最佳答
如何为站点的某些部分强制使用 HTTPS,例如登录页面或注册页面,并为站点的其余部分使用 HTTP? 最佳答案 我最喜欢的强制转换为 https 的方法是将其作为您的 php 脚本中的第一件事。它适用
我一直在慢慢学习 Ruby(在这一点上,这可能是我投入大量时间实际学习的第一门语言)所以这对你们中的许多人来说可能是一个非常简单的问题。 我的学习玩具项目基本上是一个 roguelike。目前,我有一
我正在使用Liip Cache Control bundle处理项目中的缓存。通过使用此捆绑包,您可以像这样配置缓存: liip_cache_control: rules: -
在上个月的某个时候,一个随机网站决定在一个框架中为我公司的网站提供服务。忽略“他们在做什么?”的问题。一分钟,我使用了一些简单的 frame-buster Javascript: if (top.l
假设我有以下 Numpy 数组: array([[3, 5, 0], [7, 0, 2]]) 我现在想在值不为 0 的地方加 2。最快的方法是什么?我必须操纵相当大的多维数组? 最佳答案 在我看来:
我是 git 的新手,我正尝试在 Github 项目上进行协作。我 fork 了一个项目,添加了功能,并根据自己的需要移植到了 Android。添加的功能需要在基础项目中,而不是 android 相关
在以下两个命令中,第二个抛出异常说“未知编解码器 libfdk_aac”。谁能指出我,可能是什么问题? $> ffmpeg -loglevel verbose -re -i /var/mp4s/tes
我正在尝试 nvidia 的展开循环指令,但还没有找到有选择地打开它的方法。 假设我有这个... void testUnroll() { #pragma optionNV(unroll all
我们公司最近开始使用git-flow,我们遇到了以下问题: 我们有一个控制应用程序日志级别的 DEV_MODE bool 值,我们希望开发分支始终具有 DEV_MODE=true。 但是,在发布版本时
我试图在我的 DataFrame df 中删除 nan 值,但是我很难在不影响整行的情况下删除每一列。下面是我的 df 示例。 Advertising No Advertising nan
我已将播放服务更新到最新版本,目前为 9.2.0,我还想为谷歌播放服务使用选择性模块。 // compile 'com.google.android.gms:play-services:9.2.
我是一名优秀的程序员,十分优秀!