【发布时间】:2014-12-29 15:40:44
【问题描述】:
我创建了一个自定义 UITableView 单元格,其中包含一个 UIImage 和一些标签。我已将 UIImage 标记为 100 并尝试按如下方式对其进行更新:
import UIKit
class SecondViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
let Items = ["Altitude","Distance","Groundspeed"]
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.Items.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel?.text = self.Items[indexPath.row]
var CellImageView: UIImageView? = cell.viewWithTag(100) as UIImageView?
CellImageView!.image = UIImage(named: "Airspeed")
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我应该如何更新 UIImage?我目前在运行我的应用程序时收到 EXC_BAD_INSTRUCTION 错误。
【问题讨论】:
标签: ios iphone uitableview swift uiimage