Ios UITableViewCell don';当使用较大的文本时,不要更改布局
我有一个Ios UITableViewCell don';当使用较大的文本时,不要更改布局,ios,uitableview,accessibility,dynamic-type-feature,Ios,Uitableview,Accessibility,Dynamic Type Feature,我有一个UITableView,如下所示: 当用户更改iOS文本大小设置时,布局将更改 布局会发生变化,细节标签会被压到标题下,而披露指标会变得非常大。标准单元布局和自定义单元布局以及我自己的UILabel子视图都会出现这种情况 我还没有准备好支持动态类型,所以有没有办法不允许iOS更改我的uitableviewcell的布局?已经为iOS做了很多事情来帮助表视图单元格中的动态类型实现⟹ 比如说 我在一个空白项目中重现了最初的问题,如下所示: 由于没有额外的代码,并且仅由于iOS本机实
UITableView
,如下所示:
当用户更改iOS文本大小设置时,布局将更改
布局会发生变化,细节标签会被压到标题下,而披露指标会变得非常大。标准单元布局和自定义单元布局以及我自己的UILabel
子视图都会出现这种情况
我还没有准备好支持动态类型,所以有没有办法不允许iOS更改我的
uitableviewcell
的布局?已经为iOS做了很多事情来帮助表视图单元格中的动态类型实现⟹ 比如说
我在一个空白项目中重现了最初的问题,如下所示:
由于没有额外的代码,并且仅由于iOS本机实现,请注意:
- 当到达第一个可访问性步骤时,标签会重新排序
- 系统附件元件尺寸根据使用的动态类型而变化
- 有一个自动调整行高的功能
class MyTableViewCell: UITableViewCell {
@IBOutlet weak var myTitle: UILabel!
@IBOutlet weak var myDetail: UILabel!
static let reuseIdentifier = "myReuseIdentifier"
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setUpElementsAndConstraints()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setUpElementsAndConstraints()
}
private func setUpElementsAndConstraints() {
//Custom your labels and their constraints in here.
//For the demo, everything is hard coded within the Interface Builder.
}
}
adjustsFontForContentSizeCategory
为false的标签添加到标签中,以便进行修改
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> MyTableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: MyTableViewCell.reuseIdentifier,
for: indexPath) as! MyTableViewCell
let accessoryImageFrame = CGRect(x: 0.0, y: 0.0,
width: 40.0, height: 40.0)
let accessoryImageView = UIImageView(frame: accessoryImageFrame)
accessoryImageView.image = UIImage(named: "MyChevron")
cell.accessoryView = accessoryImageView
return cell
}
override func tableView(_ tableView: UITableView,
heightForRowAt indexPath: IndexPath) -> CGFloat { return 50.0 }