简体   繁体   English

XCode 7.1.1 TableViewCell的内容视图比单元格窄

[英]XCode 7.1.1 TableViewCell's Content View narrower than cell

Since upgrading an older Swift 1.1 (I think) project to the latest XCode and swift syntax, the Storyboard seems all messed up. 自从将较旧的Swift 1.1(我认为)项目升级到最新的XCode和swift语法以来,情节提要似乎一团糟。 The most glaring bug that I can't seem to solve is in a UITableView. 我似乎无法解决的最明显的错误是在UITableView中。

I have a UITableViewCell with a standard Content View inside, which XCode wants to be 810px wide, as opposed to the cell, which is 1024px wide. 我有一个带有标准Content View的UITableViewCell,它的XCode希望为810px宽,而不是单元格为1024px宽。

I've tried to fix this by opening the storyboard in source code mode and changing the 810 to 1024, but the changed value reverts to 810 when reopening the storyboard back in the default "graphics" mode. 我试图通过在源代码模式下打开情节提要并将810更改为1024来解决此问题,但是当以默认的“图形”模式重新打开情节提要时,更改后的值恢复为810。

...
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8zh-sj-0jQ" id="fLL-9o-aQq">
    <rect key="frame" x="0.0" y="0.0" width="810" height="43"/>
    ...

Any idea how to solve this? 任何想法如何解决这个问题?

Whatever you do to UITableViewCell 's content view, is not gonna matter really as it'll be set right before getting drawn on screen by the UITableView . 不管您对UITableViewCell的内容视图做什么,都没有关系,因为它会在由UITableView绘制在屏幕上之前进行设置。 My suggestion is to reset all layout settings for contentView and use layout constraints for the views inside the contentView . 我的建议是重置内容查看所有的布局设置和使用布局约束的内容查看里面的意见。 If it still doesn't occupy the entire space, check and see if your UITableView is wide enough. 如果仍然没有占据整个空间,请检查您的UITableView是否足够宽。

Every tableview cell has a default cell size which is set in the storyboard. 每个tableview单元都有一个默认的单元大小,该大小在情节提要中设置。 在此处输入图片说明

Try changing in that place. 尝试在那个地方改变。 Make sure your cell size matches here. 确保此处的单元格大小匹配。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当单元格从视图中滚动出时,TableViewCell的textLabel值返回1 - TableViewCell's textLabel value returns to 1 when cell is scrolled out of the view TableViewCell-自定义单元格iOS-内容 - TableViewCell - Custom Cell iOS - Content 当单元格处于焦点时,iOS将视图放在TableViewCell上 - iOS Place a View on a TableViewCell when cell is in focus Swift Xcode TableViewCell 未第一次加载 - Swift Xcode TableViewCell's Not Loading First Time 将表格视图单元格扩展到内容的高度 - Expand table view cell to the content's height 如何在iOS中重置tableViewCell的内容? - How to reset tableViewCell's content in iOS? 当点击collectionView单元格内的按钮时,如何获取表格视图行并从位于tableViewCell内的collectionView推送到viewController - how to get table view row and push to viewController from collectionView that's inside a tableViewCell when tapped button inside collectionView cell ios tableViewCell.xib文件生成多个单元格 - ios tableViewCell.xib file generate more than one cell 滑动单元格时,有没有一种方法可以从tableViewCell导航到另一个视图控制器? - Is there a way to navigate from a tableViewCell to another view controller when a cell is swiped? 此版本不支持集合视图单元格内容视图。 使用至少 Xcode 11.0 打开此文档 - This version does not support collection view cell content view. Open this document with at least Xcode 11.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM