我正在使用 Interface Builder 为 iPad 应用程序设计自定义 UITableViewCell。
我有一个专用的 XIB 文件,它有一个 UITableViewCell 作为它的 Root View 。我可以将 UITableViewCell 的宽度更改为 1024(在 XCode 右侧属性 Pane 的大小检查器中),这确实会暂时调整 Canvas 上的单元格大小。
但是,如果之后我尝试移动/调整 UITableViewCell 中的某些项目或关闭并重新打开 XIB,XCode 决定将 UITableViewCell 的宽度重置回 320(iPhone 特定宽度)。
然后 Canvas 上的单元格会遮盖单元格内的项目,并且无法设计单元格,除非我再次调整单元格的大小。一旦你绕过这个循环几次,它就会变得相当烦人。
任何人都知道我如何设置宽度以使其永久化或如何指定 UITableViewCell 是特定于 iPad 的?
重新创建...
- 文件 > 新建 > 文件...
- 用户界面 > 空
设备系列 == iPad
将一个新的 UITableViewCell 拖到 Canvas 上(尽管之前选择了 iPad,但它的创建宽度为 320)
- 将 UITableViewCell 的宽度调整为 1024(目前一切正常)
- 将 UILabel 拖放到 UITableViewCell 的左侧(仍然很好)
- 通过拖动一个角以任何方式调整 UILabel 的大小(不要使用属性检查器) - 并且... UITableViewCell 的大小重置回 320
编辑:
我刚刚收到 Apple 对我多年前创建的 Radar 票证的以下回复...
你好,奥利弗,
This is a follow-up regarding regarding Bug ID# 13222753.
Engineering has requested the following information in order to further investigate this issue:
We believe this issue has been addressed in the latest Xcode 5.1 Seed.
This is a pre-release version of the Xcode developer toolset for Mac, iPhone, and iPad. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building OS X and iOS apps. Please test with this release, and update your bug report with the results.
Xcode 5.1 Seed - Build 5B71f Posted Date: Dec 13, 2013
我也刚刚尝试在 Xcode 5.0.2 中重现该问题,看起来它也已通过该构建得到修复。
最佳答案
我不知道您是否认为这是一个有效的答案,但这个问题似乎只在我使用 IB 中的 autolayout 时出现。如果我关闭它,Xcode 调整 UITableViewCell 大小的问题就会消失。
要关闭 autolayout,只需选择 UITableViewCell,然后在“文件检查器”的右侧,有一个用于关闭 autolayout 的复选框。
关于objective-c - Interface Builder 不断重置我的自定义 UITableViewCell 的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14375552/