UITableView顯示單元格,並且它們正在加載它們應該的樣子。然而,在方面適合的情況下,在單元格內部存在圖像視圖。直到您滾動,它們纔會顯示完整大小,然後向上滾動,然後顯示正確。UITableView不顯示單元格,除非滾動
下面是我正在談論的兩個圖像。我也嘗試重新加載ViewDidLoad上的數據。
當加載: http://www.screencast.com/t/oj4xdQtyv
當滾動,滾動和備份: http://www.screencast.com/t/0uHn5Wms53
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
imageIndex = indexPath.row
var cell : CustomCell = tableView.dequeueReusableCellWithIdentifier("CustomCell", forIndexPath: indexPath) as! CustomCell
cell.imgview.backgroundColor = UIColor(red: 27, green: 27, blue: 27, alpha: 1.0)
cell.imgview.layer.borderColor = UIColor.redColor().CGColor
cell.imgview.layer.borderWidth = 2
cell.imgview.image = UIImage(named: images[imageIndex]) /*Image provided*/
cell.imgview.contentMode = UIViewContentMode.ScaleAspectFit
cell.imgview.userInteractionEnabled = true
cell.imgview.tag = imageIndex
return cell
}
確保您在'cellForRowAtIndexPath'委託中使用'dequeReusableCellWithIdentifier:forIndexPath'而不是'dequeueReusableCellWithIdentifier'。非索引路徑版本有大小類的問題,它看起來像你最初的單元格認爲屏幕比它更廣泛。要做更多事情,需要查看單元格的行代碼以及如何定義單元格高度。 –
我現在將添加上面的代碼。 –
你的圖片看起來很窄?你是否讓桌面視圖比屏幕更窄? –