且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 TableView 中添加行

更新时间:2023-12-04 08:37:34

我不确定你的问题到底是什么,但我认为如果你向我们展示你的表视图委托的 -tableView 会更清楚:numberOfRowsInSection:-tableView:cellForRowAtIndexPath: 方法.这些是您将更改表视图行为的关键点,这可能是您的答案开始的地方.

I'm not sure exactly what your question is here but I think it will be much clearer if you show us your table view delegate's -tableView:numberOfRowsInSection: and -tableView:cellForRowAtIndexPath: methods. These are the key points where you'll make changes to your table view's behavior, and this is where your answer is likely to start.

好的.这有点令人困惑——它看起来像 myTableView 是一个 NSArray?通常,具有类似名称的变量应该是指向表视图的指针.但是 UITableView 既没有 -addObject: 方法也没有 -count 方法.

Okay. This is a little confusing -- it looks like myTableView is an NSArray? Normally a variable with a name like that would be expected to be a pointer to a table view. But UITableView has neither an -addObject: method nor a -count method.

如果是这样,看起来你很好(虽然我真的认为你应该重命名该数组).您应该在 UITableView 上调用 -reload* 方法之一,让它知道数据已更改.最简单的是

If that is the case, it looks like you're good (though I really think you should rename that array). You should call one of the -reload* methods on your UITableView to let it know that the data has changed. The simplest is

[ptrToTableView reloadData];

但是只要多做一点工作,您就可以使用 -reloadSections:withRowAnimation: 获得更好的结果.

but with a little more work you can get fancier results with -reloadSections:withRowAnimation:.

如果这不能回答问题,那么我不确定问题是什么.:)

If this doesn't answer the question, then I'm not sure what the question is. :)