这是我的第一个 swift 项目,我尝试制作一个应用程序内设置页面。 所以我有一个基本的 UITabelView ,里面有自定义的 UITableViewCell 。我的 UITableViewCell 左侧包含一个 UILabel,右侧包含一个 UISwitch。
问题是 UITableViewCell 长度是静态的(我认为),当我在 iPhone 6 plus 上编译时,结果如下:
当我在 iPad 空气模拟器上编译时,我没有单元格。
那么如何动态调整 UItableViewCell 长度呢?
最佳答案
这里有一个简单的方法来修复它。
在您的 TableCell.m 中
在创建 UISwitch 时添加此内容
objective-c :
switch.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
swift :
switch.autoresizingMask = .FlexibleLeftMargin;
关于ios - 将 UITableViewCell 的长度调整为 UITableView 的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36715321/