我以某种方式在带有静态单元格的情节提要中创建了一个 UITableViewController,并且能够在 UITableView 顶部添加一个 UINavigationBar。我现在正在尝试使用新的 iOS7 状态栏偏移量,并试图查看哪个视图在哪个视图中,这就是我注意到这一点的时候:

我一直在尝试重新创建它,但这是不可能的。XCode 不允许我在 UITableView 部分的顶部或之前添加 UINavbar。相反,它总是这样做:

导航栏甚至在表格视图之外。
任何想法为什么?
我以某种方式在带有静态单元格的情节提要中创建了一个 UITableViewController,并且能够在 UITableView 顶部添加一个 UINavigationBar。我现在正在尝试使用新的 iOS7 状态栏偏移量,并试图查看哪个视图在哪个视图中,这就是我注意到这一点的时候:

我一直在尝试重新创建它,但这是不可能的。XCode 不允许我在 UITableView 部分的顶部或之前添加 UINavbar。相反,它总是这样做:

导航栏甚至在表格视图之外。
任何想法为什么?
编辑
我只是能够在 Xcode 5 的故事板中的 UITableViewController 中的 UITableView 的表头视图中放置一个 UINavigationBar。诀窍是将它放在 UITableView 的最顶部。为了更容易,您可以配置模拟指标以显示顶部导航栏并将导航栏组件放在其顶部。它就位。
回覆。评论中关于将其向下推 20px 的附加问题。除非您使用实际的 UINavigationController,否则没有自动方法。您可以手动将 tableview 内容插入设置为为上边距指定 20 个点。
原来的
看起来好像您可以将其添加UINavigationBar为表头视图。我无法通过 IB 做到这一点,但我能够添加一个导航栏作为表页脚视图。然后我进入xml源并将navigationBar元素的“key”属性从“ tableFooterView”更改为“ tableHeaderView”。在 IB 中打开它会使布局和你的一样。
通过 IB 在表头视图中获取 UINavigationBar 的另一种方法是将 UIView 拖到那里并更改类类型。但这不会改变 IB 窗口——对于 IB,它只是一个 UIView。
这是情节提要 XML 后期修改:
<scene sceneID="AAh-fX-ffB">
<objects>
<tableViewController id="aWk-nr-T8Z" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="UP8-s3-1Gh">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<navigationBar key="tableHeaderView" contentMode="scaleToFill" id="VMO-sB-hzN">
<rect key="frame" x="0.0" y="110" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<items>
<navigationItem title="Title" id="cGh-ax-HpR"/>
</items>
</navigationBar>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="XpO-wE-6cr">
<rect key="frame" x="0.0" y="66" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="XpO-wE-6cr" id="VKA-tU-Yjw">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="aWk-nr-T8Z" id="n7K-0q-ZI8"/>
<outlet property="delegate" destination="aWk-nr-T8Z" id="ZFM-QX-8D4"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yCS-a8-E82" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="201" y="200"/>
</scene>
我认为两者之间的区别在于第一个是标准视图控制器。第二个是 tableview 控制器。在标准的拖出 tableview 控制器中,您无法调整 tableview 的大小,以便您有空间在导航栏中拖动。
如果你拖出一个标准的视图控制器然后拖出一个tableview控制器,你可以调整tableview的大小,使它不会填满整个屏幕,你可以手动添加一个导航栏。
出于某种原因,Xcode 只是不喜欢您向 tableview 控制器添加导航栏。