私はfew of these tutorialを経由しています。ボタンをクリックすることで私の機能を呼び出すようです。私はこの男のtutorialに従っているが、何も動かない。アクションボタンがUITable内で動作しない
私のtableView
現在のところうまく働いていますが、私は今、データを別のビューに渡すことができるようにボタンを追加していますが、ボタンのクリックでその機能が呼び出されていません。
//class IncomeFeedCell: UITableViewCell:
@IBOutlet var weak button: UIButton!
ビューContoller:今
// class IncomeFeedVC: UIViewController, UITableViewDelegate, UITableViewDataSource:
// viewDidLoad:
tableView.delegate = self
tableView.dataSource = self
// cellForRowAt indexPath
let cell = self.tableView.dequeueReusableCell(withIdentifier: "IncomeFeedCell") as! IncomeFeedCell
cell.button.tag = indexPath.row
cell.button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
cell.configureCell(income: income)
return cell
タップしたときに呼び出す関数:
func buttonPressed(){
print("Tapped")
}
シミュレータ:
私は何かを逃したことがありますか?
編集:と助けようとしたと私はより多くの重要な情報を残しているためdownvotedてしまったすべての人のための
謝罪。このすべてがIncomeFeedVC
に私のviewDidLoad
内にある:
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
DataService.ds.REF_INCOMES.queryOrdered(byChild: "date").observe(.value, with: { (snapshot) in
/**
* Sorting the object before looping over
* Info here: http://stackoverflow.com/questions/41416359/sort-firebase-data-with-queryordered-by-date
*/
guard let incomeSnap = snapshot.value as? [String:AnyObject] else{
return
}
let sorted = incomeSnap.sorted{($0.0.value["date"] as! Double) > ($0.1.value["date"] as! Double)}
for snap in sorted {
if let incomeDict = snap.value as? [String: AnyObject] {
let key = snap.key
let income = Income(incomeId: key, incomeData: incomeDict)
self.incomes.append(income)
}
}
self.tableView.reloadData()
})
@HimanshuMoradiya何がどこにありますか? – Sylar
cell.button.addTarget(self、action:#selector(buttonPressed)for:.touchUpInside)この行とfunc buttonPressed(){ print( "Tapped") }ファンクション –
質問が不明です。正確な問題は何ですか?ボタンをタップするとどうなりますか? – rmaddy