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

查看:116
本文介绍了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以模态方式呈现它。导航栏会阻止显示的视图控制器的表视图。我将 automaticAdjustsScrollViewInsets 设置为 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. 两个视图控制器'autoAdjustsScrollViewInsets设置为YES

  2. 项目未使用故事板

  3. 第一个是在Xcode 4.6创建的,第二个是在Xcode 5上新创建的

  4. 我比较了两个类xib和代码,差别不大

  1. Two View Controllers' automaticallyAdjustsScrollViewInsets set to YES
  2. The project is not using storyboard
  3. The first one is created at Xcode 4.6, The second one is newly created on Xcode 5
  4. I have compared two classes xib and code, not much different


推荐答案

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

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

第一个,添加的视图控制器是一个UITableViewController。
由于apple将自动填充,因此不应出现此问题它。

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.

这是Apple开发者论坛链接(需要开发者帐户才能访问):
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天全站免登陆