Iphone 使用tableview:CommittedItingStyle:ForRowatineIndexPath:后,触摸界面出现tableview删除错误
我正在重写tableView:CommittedItingStyle:ForRowatingIndexPath,使其成为一种重置我的uitableviewcells中的文本标签的方法,但是当用户下次触摸uitableview时,这可能会导致错误。。在它做任何事情之前,必须触摸它一次(因此需要两次触摸才能得到任何响应) 我希望有人能帮助同样处于类似情况的人;。我的代码在下面。。我已经调试到tableView:CommittedItingStyle:forRowAtIndexPath方法,就像我注释掉tableView:TitleForDeleteConfirmationButtonFrrowatindXPath:method一样,同样的事情仍然发生。。因此,我认为我重写了另一个方法,这是做错了什么Iphone 使用tableview:CommittedItingStyle:ForRowatineIndexPath:后,触摸界面出现tableview删除错误,iphone,ios,uitableview,Iphone,Ios,Uitableview,我正在重写tableView:CommittedItingStyle:ForRowatingIndexPath,使其成为一种重置我的uitableviewcells中的文本标签的方法,但是当用户下次触摸uitableview时,这可能会导致错误。。在它做任何事情之前,必须触摸它一次(因此需要两次触摸才能得到任何响应) 我希望有人能帮助同样处于类似情况的人;。我的代码在下面。。我已经调试到tableView:CommittedItingStyle:forRowAtIndexPath方法,就像我注释
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Clear";
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
//[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
//reset uitableviewcell textlabel with default input "empty"
vehicleSearchObjectString = @"empty";
[self.tableView reloadData]; //reloads the tabels so you can see the value.
}
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
}
}
更新
这是我设置uitableviewcell文本标签的地方
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"VehicleSearchCell" owner:self options:nil];
cell = vehicleSearchCell;
self.vehicleSearchCell = nil;
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UILabel *label1;
label1 = (UILabel *)[cell viewWithTag:1];
label1.text = @"Manufacture";
UILabel *label2;
label2 = (UILabel *)[cell viewWithTag:2];
label2.text = vehicleSearchObjectString;
}
//...
如果使用这种方法,您已经启用了对表的编辑,我建议您检查禁用的位置/时间,因为这可能是导致单击看起来被忽略的原因 我将遵循的另一条线索是避免重载数据方法,该方法引发了很多事情,有时开发人员无法控制。您已经有了indexPath,因此可以使用以下方法将单个单元格作为更新的目标:
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
在表视图上
我要调查的最后一件事是苹果对更新表格的评论:
上面说提交。。。方法必须调用以下方法:
deleteRowsAtIndexPaths:withRowAnimation:
或者类似于insert,但是如果没有,则不会发生什么。所以我已经解决了这个问题!。。。我基本上删除了视图。h.m.xib再次启动,几乎将我的代码复制到了文件中,它工作得非常完美。。。我不知道为什么会发生这种事,也许是我第一次安装时做的。。我不确定…什么是错误/问题?撞车?什么?一旦我按下按钮,单元格的uitextlabel设置为“空”,如果我尝试按下该文本单元格(这会将我带到子视图),它不会在第一次触摸时做出响应。。它会在第二天作出反应。。这就像我的整个uitableview变得没有响应一样。车辆搜索对象字符串:这是什么?您在哪里将其设置为触摸(要删除)的tableViewCell?它是在我的主视图中声明的NSString,由我设置的子视图协议设置。确定。那么,您在哪里将UITableViewCell设置为“空”呢?好的,谢谢您的建议。。我现在要看一遍:)谢谢。很明显,如果我让他们中的任何一个开始,我会给你赏金。我已经尝试过瞄准我的细胞进行更新,但一旦有一个被刷过,它仍然会影响整个桌子。。。看看你的其他建议。。