2
我已經使用代碼創建了UITableView和UITableViewCell的子類,並且它顯示完美無缺,直到我選擇單元格。UITableViewCell textLabel選擇的位置變化
該電池的爲textLabel將向右移動或不選擇
相關之後選擇之前轉移的問題有時
圖像表示
圖像表示中的問題的代碼
class MyCell: UITableViewCell {
override func layoutSubviews() {
super.layoutSubviews()
// here I fixed the image at a specific point
self.imageView?.bounds = CGRectMake(0, 0, 100, 125)
self.imageView!.frame = CGRectMake(0, 0, 100, 125)
self.imageView?.contentMode = .ScaleAspectFill
} }
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = MyCell(style: UITableViewCellStyle.Default, reuseIdentifier: "FeedCell")
self.configureCell(cell, atIndexPath: indexPath)
return cell
}
func configureCell(cell: MyCell, atIndexPath indexPath: NSIndexPath) {
let item = self.items[indexPath.row] as MWFeedItem
cell.textLabel?.text = item.title
cell.textLabel?.font = UIFont.systemFontOfSize(12.0)
cell.textLabel?.numberOfLines = 0
}
對於任何人回到這個問題。每當單元格移動到選定狀態時,我的自定義單元格中的textLabel都會跳躍。我所做的只是在自定義單元格中定義自己的textLabel屬性,並從內置的textLabel屬性切換到新的自定義單元格。繁榮!問題解決了! – iOS4Life