匹配的定制和放大器的左对齐;标准的UITableViewCell类型 [英] Matching left alignment of custom & standard UITableViewCell types

查看:216
本文介绍了匹配的定制和放大器的左对齐;标准的UITableViewCell类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在故事板定义自定义的UITableViewCell 秒。我还使用一些内置的标准样式的细胞。我需要设置的限制,使我的自定义细胞与平台上定义的(有他们的头衔正确地在左边对齐)。

I'm defining custom UITableViewCells in a storyboard. I'm also using some of the built in standard style cells. I need to set up constraints so that my custom cells match with the platform defined ones (have their titles correctly aligned at the left).

我注意到的IOS版本和它的运行对设备之间的细胞变化的左对齐。它的看起来的像左对齐相同的默认单元格 separatorInset

I've noticed that the left alignment of cells changes between iOS versions and the device it's running on. It seems like the left alignment is the same as the default cell separatorInset.

下面是的UITableViewCell 取值 separatorInset 几设备和iOS版本:

Here is UITableViewCells separatorInset for a few devices and iOS versions:


  • 的iPad上。7 - 15分

  • 的iPad上8 - 20点

  • 在7 iPhone - 15点

  • 在8 iPhone - 16点

其他设备(iPhone 6+,iPad的迷你型)可能是不同的 - 我还没有详尽的检查

Other devices (iPhone 6+, iPad Mini) could be different – I've not exhaustively checked.

如何去确保定制单元和内置在细胞有它们的标签相同的左对齐?

How would you go about ensuring that the custom cells and built in cells have the same left alignment of their labels?

有没有一种合理的方式获得这些插图默认值,并在那些设立在故事板自动布局限制使用它们?怎么样在code?

Is there a sensible way to obtain these inset defaults and use them in auto layout constraints that are set up in a storyboard? How about in code?

推荐答案

我有同样的问题,但对方的回答,因为我是使用静态细胞的UITableViewController不能帮助我。一些试验和错误之后,我终于找到一个方法来解决iPhone 6+ separatorInset 问题,而code一行。

I was having the same issue but the other answer couldn't help me as I was using static cells in UITableViewController. After a few trial-and-errors, I finally found a way to solve the separatorInset issue on iPhone 6+ without a single line of code.

我只是对准的UILabel的左边缘从左边距0 [查看内容(当前距离= 0)]的数值。 ,改变它的UILabel的X位置获得0(对于我的情况下,在Interface Builder,利润率为7,UILabel的X = 8)。对齐效果很好的iPhone 4S,5S,6和6 +

I simply align the left edge of the UILabel with value of 0 [Content View (current distance = 0)] from the left margin. And also change the UILabel's X position to get 0. (For my case, in Interface Builder, margin was 7, UILabel's X = 8). The alignment works well on iPhone 4S, 5S, 6 and 6+.

编辑:这改变了X code 7。
额外的步骤:将preserve的SuperView页边距的相应单元的 TableViewCell 内容查看为TRUE或支票它IB - >尺寸督察。请参阅@ tebs1200的回答。

This changed in XCode 7. Additional step: Set "Preserve Superview Margins" of the respective cell's TableViewCell and its contentView to TRUE or check it in IB -> Size Inspector. Refer to @tebs1200's answer.

希望这有助于。

这篇关于匹配的定制和放大器的左对齐;标准的UITableViewCell类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆