我有一個自定義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