iOS 7 表格视图无法自动调整内容插入 [英] iOS 7 Table view fail to auto adjust content inset

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

问题描述

我正在将我的项目转换到 iOS7.我正面临一个与半透明导航栏相关的奇怪问题.

I am transiting my project to iOS7. I am facing a strange problem related to the translucent navigation bar.

我有一个视图控制器,它有一个 tableview 作为子视图(我们称之为 ControllerA).我使用 controllerA 初始化一个新的 uinavigationcontroller,并使用presentviewcontroller 以模态方式呈现它.呈现的视图控制器的表格视图被导航栏挡住了.我将 automaticallyAdjustsScrollViewInsets 设置为 YES,但结果没有改变.我知道我可以将 edgesForExtendedLayout 设置为 UIRectEdgeNone,但这会使导航栏不再透明.

I have a view controller and it has a tableview as subview (let's call it ControllerA) . I init a new uinavigationcontroller with the controllerA and present it modally using presentviewcontroller. The presented view controller's table view is blocked by the navigation bar. I set the automaticallyAdjustsScrollViewInsets to YES but the result did not change. I knew I can set the edgesForExtendedLayout to UIRectEdgeNone, but it will make the navigation bar no more translucent.

在那之后,我尝试创建一个新的视图控制器进行测试.它包含几乎相同的元素.但结果却大不相同.表视图内容不会被阻止.

After that, I tried to create a new view controller for testing. It contains almost the same elements. But the result is much different. The table view content does not get blocked.

结论

  1. 两个视图控制器的 automaticAdjustsScrollViewInsets 设置为 YES
  2. 该项目没有使用故事板
  3. 第一个是在 Xcode 4.6 上创建的,第二个是在 Xcode 5 上新创建的
  4. 我比较了两个类xib和code,差别不大

推荐答案

我在苹果开发者论坛上找到了答案.有两种不同的情况.

I have found the answer on apple developer forum. There are two different case.

第一个,添加的视图控制器是一个 UITableViewController.而且这个问题应该不会出现,因为苹果会自动填充它.

The first one, the view controller added is a UITableViewController. And the issue should not be appeared since apple will auto padding it.

第二个,视图控制器不是 UITableViewController.在视图层次结构中,它包含一个 UITableView.在这种情况下,如果 UITableview(或 ScrollView)是 viewController 的主视图或主视图的第一个子视图,它将起作用.否则,视图控制器不知道要填充哪个滚动视图,就会发生问题.

The second one, the view controller is NOT a UITableViewController. And in the view hierarchy, it contains a UITableView. In this case, if the UITableview(or ScrollView) is the viewController's mainview or the first subview of the mainview, it will work. Otherwise, the view controller doesn't know which scroll view to padding and it will happen the issue.

就我而言,视图控制器是第二个.并且有一个背景图像视图作为主视图的第一个子视图.所以,它失败了.

In my case, the view controller is the second one. And there is a background image view as the first subview of the main view. So, it fails.

这里是苹果开发者论坛链接(需要开发者账号才能访问):https://devforums.apple.com/message/900138#900138

Here is the Apple developer forum link (need developer account to access): https://devforums.apple.com/message/900138#900138

这篇关于iOS 7 表格视图无法自动调整内容插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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