私はこれに続きましたtutorial。コードがどのように見えるテーブルビューにセルを追加するには、このtoDoItems.append(ToDoItem(text: "CHILDS NAME"))
Fireviewのテーブルビューセル
これはtoDoItem
次のとおりです。
func toDoItemAddedAtIndex(index: Int) {
let toDoItem = ToDoItem(text: "")
toDoItems.insert(toDoItem, atIndex: index)
tableView.reloadData()
// enter edit mode
var editCell: TableViewCell
let visibleCells = tableView.visibleCells as! [TableViewCell]
for cell in visibleCells {
if (cell.toDoItem === toDoItem) {
editCell = cell
editCell.label.becomeFirstResponder()
break
}
}
}
そして、これがToDoItems
です:
func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! TableViewCell
cell.selectionStyle = .None
cell.textLabel?.backgroundColor = UIColor.clearColor()
let item = toDoItems[indexPath.row]
// cell.textLabel?.text = item.text
cell.delegate = self
cell.toDoItem = item
return cell
}
そして、私のfirebase database
は次のようになります。
JSON:
"Mission-list" : {
"vJGnbbJX9lbBYwgesjHfNqdzmJs2" : {
}
}
質問:どのように私は、自動的にそれぞれの子のためのテーブルビューセルが怒鳴るミッションリストに追加追加しのですか?そして、セル名を子の名前に設定します。
ありがとうございます!
* toDoItems *とは何ですか? * cellForIndexPath *からの関連するコードも、Firebaseのデータを取得する場所に関数を与えます。JSON構造体をテキストではなくテキストとして渡すと、ナビゲートするのがもっと簡単になります。 – Dravidian