gpt4 book ai didi

ios - UITableViewCell AccessoryView 显示不正确

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:18 26 4
gpt4 key购买 nike

我在 accessoryView 中有一个带有 UISwitch 的 UITableviewCell,它在运行时正确显示,但是一旦我旋转设备,开关就不再位于正确的位置。 the wrong place for accessoryView

我可以使用约束而不使用 accessoryView,但我想我可以使用这个字段..有人有想法吗?

谢谢!

编辑:这是 Interface Builder 中的配置: enter image description here

编辑 2:我使用了自定义单元格: enter image description here

对默认属性进行初始化:

self.textLabel.font = [UIFont preferredDynamicFontForTextStyle:UIFontTextStyleBody fontSize:16.0];
self.backgroundColor = self.contentView.backgroundColor;

self.textLabel.text = item.title;
self.selectedImage = item.imageSelected;
self.unselectedImage = item.image;
self.imageView.image = self.unselectedImage;
// if I do it programmatically
self.accessoryView = [[UISwitch alloc] init];

我根本不设置约束,因为我使用默认属性..

最佳答案

我和你有同样的问题。

这是我的观察:

  • 如果您通过代码设置 accessoryView,无论 cell 是否被选中,在 iOS 7 和 iOS 8 上都没有问题。
  • 如果您通过 IB 设置 accessoryView,则 accessoryView 移动到左上角在第一次选择单元格后,并且仅在 iOS 8 上

我不知道问题是来自 IB 还是单元格在 iOS 8 上布局附件 View 的方式,但到目前为止,解决方法很简单:始终通过代码设置附件 View 以避免意外行为。

关于ios - UITableViewCell AccessoryView 显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29733582/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com