-1
我有3個功能:如何在swift中使用多個tableView函數?
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruits.count
}
和
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 1 {
self.performSegueWithIdentifier("Herp", sender: self)
}
}
和
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
-> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("FoodList", forIndexPath: indexPath)
as UITableViewCell
let fruit = fruits[indexPath.row] as Fruit
cell.textLabel?.text = fruit.name
cell.detailTextLabel?.text = fruit.desc
return cell
}
有沒有辦法將它們組合成一個單一的功能,而不是有3層獨立的tableView的功能呢?
您是否理解代表或事件的概念? – 2015-03-02 15:41:07