Iphone 表数据重新加载问题
请参阅下面的代码,它将从数组中删除对象,但不会重新加载表Iphone 表数据重新加载问题,iphone,tableview,reload,Iphone,Tableview,Reload,请参阅下面的代码,它将从数组中删除对象,但不会重新加载表 - (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@" commitEditingStyle"); if (editingStyle == UITableVie
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@" commitEditingStyle");
if (editingStyle == UITableViewCellEditingStyleDelete)
{
NSLog(@" commitEditingStyle Delete ");
[self.arry removeObjectAtIndex:indexPath.row];
[tableView reloadData];
} else if (editingStyle == UITableViewCellEditingStyleInsert)
{
NSLog(@" commitEditingStyle Insert ");
[self.arry insertObject:@"New Row" atIndex:[arry count]];
[tableView reloadData];
}
}
此外,我还有[tableView reloadData]
在视图中写入的将出现&视图加载
,但它不会重新加载
TableView
通过故事板添加到ViewController,IBoutlet添加到.h
文件
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
ForRowatineXpath:(NSIndexPath*)indexPath{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[arryData removeObjectAtIndex:indexPath.row];
[tblSimpleTable reloadData];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
[arryData insertObject:@"Mac Mini" atIndex:[arryData count]];
[tblSimpleTable reloadData];
}
}
使用类似的方法您必须将消息发送到您的出口(如果您有一个出口,即self.tableView
),或者直接发送到调用委托方法的tableView:[aTableView reloadData]代码>(注意a)
如果仔细查看方法签名,您将看到tableView实例作为aTableView
传递给您:
-(void)tableView:(UITableView*)
或tableView..从何处获取self.arry数据?您在哪里添加数据?您必须将消息发送到您的出口(如果您有一个出口,即self.tableView
),或直接发送到调用委托方法的tableView:[aTableView reloadData]代码>(注意a
)您选中了“插入”和“删除”这两个选项都不起作用???对于insert[self.arry insertObject:@“新行”索引:[arry count]+1]代码>@iPatel:两者都不起作用在ViewWillAspect方法中创建NSMutableArray