我有一个自定义UITableViewCell与.xib。在xib中,我已将单元格宽度设置为320.自定义UITableViewCell宽度问题
我想在单元格内相对于单元格宽度定位UIlabel。但是,在运行时的代码中,单元格的Bounds.width总是320,如在xib中设置的,而不是屏幕/ UITableView的实际宽度,我需要正确定位UILabel。
显然,至少在运行期间,iPhone 5,6和6+的宽度应该不同,但在所有设备上始终设置为320。我错过了什么?
谢谢!
编辑
这是一小段代码。
var newFrame = _lblDetail.Frame;
newFrame.X = Bounds.Width - 55; //get current width of cell, and subtract 55 and set that as the X value of the frame for the label
_lblDetail.Frame = newFrame; //set new frame on label
没有符合你检查表视图的宽度?它也是320吗?你能否添加一些代码或相关的截图? –
是的,tableview的宽度也是320.添加了一些代码 – Corstiaan