iOS 7:自定义容器视图控制器和内容插入 [英] iOS 7: Custom container view controller and content inset

查看:87
本文介绍了iOS 7:自定义容器视图控制器和内容插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含在导航控制器中的表视图控制器。当通过 presentViewController:animated:completion:呈现时,导航控制器似乎会自动将正确的内容插入应用于表视图控制器。 (任何人都可以向我解释这是如何工作的吗?)

I have a table view controller wrapped in a navigation controller. The navigation controller seems to automatically apply the correct content inset to the table view controller when it is presented via presentViewController:animated:completion:. (Can anyone explain to me how this works exactly?)

但是,只要我将组合包装在自定义容器视图控制器中并将其显示为最顶端的部分表视图内容隐藏在导航栏后面。为了在此配置中保留自动内容插入行为,我能做些什么吗?我是否必须在容器视图控制器中通过某些内容才能使其正常工作?

However, as soon as I wrap the combination in a custom container view controller and present that instead, the topmost part of the table view content is hidden behind the navigation bar. Is there anything I can do in order to preserve the automatic content inset behaviour in this configuration? Do I have to "pass through" something in the container view controller for this to work correctly?

我希望避免手动调整内容或通过自动布局,因为我想继续支持iOS 5.

I'd like to avoid having to adjust the content inset manually or via Auto Layout as I want to continue supporting iOS 5.

推荐答案

感谢Johannes Fahrenkrug的提示,我想出了以下内容: automaticAdjustsScrollViewInsets 当子视图控制器的根视图是 UIScrollView 时,实际上似乎只是宣传的。对我来说,这意味着以下安排有效:

Thanks to Johannes Fahrenkrug's hint, I figured out the following: automaticallyAdjustsScrollViewInsets indeed only seems to work as advertised when the child view controller's root view is a UIScrollView. For me, this means the following arrangement works:

内容视图控制器 导航控制器里面自定义容器视图控制器

虽然这不是:

内容视图控制器导航控制器自定义容器视图控制器

然而,第二个选项似乎更多从逻辑的角度来看是明智的。第一个选项可能只有效,因为自定义容器视图控制器用于将视图附加到内容的底部。如果我想在导航栏和内容之间放置视图,那就不会那样。

The second option, however, seems more sensible from a logical point of view. The first option probably only works because the custom container view controller is used to affix a view to the bottom of the content. If I wanted to put the view between the navigation bar and the content, it wouldn't work that way.

这篇关于iOS 7:自定义容器视图控制器和内容插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆