最初我有一个只有一个添加按钮的表格 View 。
当用户按下此按钮时,我需要增加单元格计数并按如下方式添加单元格
如何写入行数以及如何通过单击添加按钮添加新行
//行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return **????** ;
}
//单元格/行上的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
??????
}
//### 添加新行.. ###
-(IBAction)myAction:(id)sender
{
???????? ;
}
提前致谢...
最佳答案
UITableView
具有插入行或部分的属性。见Apple Doc
这方面有很多教程。有 2 个常用来添加/删除行/节。
insertRowsAtIndexPaths:withRowAnimation:
deleteRowsAtIndexPaths:withRowAnimation:
我已经发布了类似的答案如何使用它: Hiding the table view cells with switch ON/OFF in iPhone
关于iphone - 如何通过按 iPhone 中的按钮将行/单元格动态添加到 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10408232/