向表中添加行
我有一个用 NSArray 添加的对象的表,名为 listOfConjProcedures 我想使用表中顶行上方出现的插入控件在点击 UInavigation 控制器中的编辑按钮时将行添加到我的表中,但我找不到好的示例代码。 编辑功能如下所示:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([tableView isEditing])
return [listOfConjProcedures count] + 1;
else
return [listOfConjProcedures count];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[listOfConjProcedures removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
我不知道如何继续使用插入功能来在点击编辑按钮时引入新行(在发布的代码的底部)。 先感谢您。
I have a table with objects added with NSArray called listOfConjProcedures I want to use an insert control that appears above the top row in the table to add rows to my table when tapping the edit button in a UInavigation controller and I cannot find a good sample code.
The edit function looks like this:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([tableView isEditing])
return [listOfConjProcedures count] + 1;
else
return [listOfConjProcedures count];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[listOfConjProcedures removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
I don't know how to proceed with the insert function to introduce a new row when the edit button is tapped (At the bottom of the posted code).
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此链接可帮助您插入新行 link1 链接2 链接3
This links helps you for insert new row link1 link2 link3