https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseDatabaseUIで説明したようにFUIIndexTableViewDataSourceを使用しています。FirebaseUI:FUIIndexTableViewDataSourceを使用しているときにsegue中にindexPathのオブジェクトにアクセスするには?
アイテムがタップされているときに詳細ビューコントローラを表示したいが、セグを準備するときに参照、キーまたはデータを取得する方法がわからない。
マイコード:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
// HELP: How do I access the firebase reference, index, and data from here?
}
}
}
そして、私は、データソースを設定しているsetupDatabase()関数で
。self.dataSource = self.tableView.bind(
toIndexedQuery: chatKeysRef,
data: chatDataRef,
delegate: self,
populateCell: {
(tableView, indexPath, dataSnapshot) in
let cell = tableView.dequeueReusableCell(withIdentifier: "Chat", for: indexPath);
if (dataSnapshot == nil) {
cell.textLabel?.text = "";
cell.detailTextLabel?.text = "";
return cell;
}
cell.textLabel?.text = "hello world"
if (dataSnapshot!.hasChild("most_recent_message")) {
cell.detailTextLabel?.text = dataSnapshot?.childSnapshot(forPath: "most_recent_message").value as? String;
}
return cell;
});
FUIIndexTableViewDataSourceが私を助ける任意のパブリックプロパティやメソッドを持っていないようです:https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseDatabaseUI/FUIIndexTableViewDataSource.h
Readme.mdはFUIDataSourceを参照するが、それはFUIIndexTableViewDataSourceに存在することがないようです。選択された行のための
ように読むことができますか? – astromme