Ore*_*ren 12 uitableview ios xcode6
在Xcode 5中,我能够将a UIView拖入UITableViewIB中以创建标题.但是在Xcode 6中,IB不会让我放弃一个.有没有办法再在IB中创建表头?
jrt*_*ton 37
您只需将a拖到UIView表格的顶部("原型单元格"文本上方)并将其保持在那里.下降指示器变为单个水平线,两端各有一个小圆圈.当你删除它时,它会生成一个标题.
你可以在底部做类似的做一个页脚.
对于故事板中的表视图控制器:

对于xib中的表视图:

小智 5
右键单击XIB文件并选择"打开为",选择源代码
查找tableview XML Element并替换为以下内容
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="YCz-1P-cVv">
<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"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="vv3-pk-N2N">
<rect key="frame" x="0.0" y="0.0" width="320" height="156"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="yho-bJ-IzF">
<rect key="frame" x="0.0" y="25" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</tableView>
Run Code Online (Sandbox Code Playgroud)
使用Interface Builder XIB Document保存并打开XIB.