在我的iOS表視圖格式。我得到TableViewDelegate
所需的功能:什麼是調用accessoryButtonTappedForRowWithIndexPath在迅速
@IBAction func showSubcategoryEditor(sender: UIButton) {
let switchFrameOrigin = sender.frame.origin
if let indexPath: NSIndexPath = self.tableView.indexPathForRowAtPoint(switchFrameOrigin) {
tableView.delegate.accessoryButtonTappedForRowWithIndexPath!(indexPath)
}
}
:
override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
savedRow = indexPath.row
self.performSegueWithIdentifier("SubcategorySegue", sender: self)
}
我第一次通過執行以下獲得indexPath
這會導致錯誤,指示委託無法識別。
我應該使用:tableView.accessoryButtonTappedForRowWithIndexPath(indexPath)
?
你不明白爲什麼你使用showSubcategoryEditor方法。那是什麼按鈕?這與附件按鈕有什麼關係,並且爲什麼要調用accessoryButtonTappedForRowWithIndexPath方法。當你點擊附件按鈕時會調用它。 – rdelmar 2015-01-31 18:15:45
這是一個表格視圖控制器,它繼承了另一個表格視圖控制器。第一個允許選擇一個類別。第二個選項允許選擇與該類別相對應的子類別。我可以用一個內置的附件按鈕來實現它,但我想用一個自定義按鈕來代替。我需要了解如何使用自定義按鈕作爲附件按鈕,該按鈕將調用方法「accessoryButtonTappedForRowWithIndexPath」。我的函數「ShowSubcategoryEditor」使用sender.frame.origin來定位按下按鈕所在的行。然後調用accessoryButton。 – 2015-02-01 23:04:45
我想要做的是替換一個自定義按鈕(嚴格爲美學),並使其表現爲系統提供的附件。不幸的是,到目前爲止我還沒有成功。幸運的是,我可以使用標準的附件按鈕,直到我弄明白爲止。 – 2015-02-04 05:53:55