【发布时间】:2015-09-19 15:07:37
【问题描述】:
我在 ViewController 中有一个 tableView 和一个名为 toDo 的数组,在 TableView 中我有一个单元格,在单元格中我有 textView。
textView 是可编辑的(用户可以更改 textView 中的文本)。
用户更改文本后 - 我希望单元格将其保存到 toDo 数组,但每当我重新加载数据时,文本就会消失。
这是我尝试过的:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: TableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath:indexPath) as! TableViewCell
cell.textField.text = toDo[indexPath.row]
cell.textField.delegate = self
return cell
}
**我有一个测试按钮,只要我点击它就会重新加载数据。
【问题讨论】:
-
请显示您正在使用修改后的文本更新 toDo 的代码。
-
代码在问题中:
cell.textField.text = toDo[indexPath.row]。除非我没有编写正确的代码.. -
这显示了你如何从 toDo 读取信息,但重要的部分是当用户更新文本时你如何写入 toDo 信息。有意义吗?
-
@MirekE 我想我没有写它。你能给我一个例子吗?
标签: ios arrays xcode swift uitableview