【发布时间】:2017-08-03 14:47:14
【问题描述】:
我下面的代码列出了 uitableview 单元格(a 和 b)上的 2 件事。我希望在写入“a”的单元格上只显示一次 gif。
import UIKit
class ViewController: UIViewController {
var i1 = ["a","b"]
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return i1.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.textAlignment = .center
cell.textLabel?.text = pets[indexPath.row]
//what I am trying to do but does not work. if the cell reads a I want the cell to display a image.
if i1[0] {
cell.imageView?.loadGif(name: "ftf")
}
return cell
}}
【问题讨论】:
-
你写的“a”是什么意思?
标签: ios arrays uitableview swift3