Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Object-C:为什么tableView在我删除单元格后不能响应任何事件?_Ios_Objective C_Iphone_Uitableview_Ipad - Fatal编程技术网

Ios Object-C:为什么tableView在我删除单元格后不能响应任何事件?

Ios Object-C:为什么tableView在我删除单元格后不能响应任何事件?,ios,objective-c,iphone,uitableview,ipad,Ios,Objective C,Iphone,Uitableview,Ipad,我创建如下视图:myController.view.aView.scrollView.tableView 在执行以下操作后,会出现问题: D_1。尝试删除一行。//by-(void)tableView:(UITableView*)tableView提交的编辑样式:(UITableView单元格编辑样式)行的编辑样式索引路径:(nsindepath*)indepath D_2。数据源删除一个数据 D_3。对数据源做些什么 D_4。[tableView relaodData]。//它正在主线程中工作

我创建如下视图:
myController.view.aView.scrollView.tableView

在执行以下操作后,会出现问题:

D_1。尝试删除一行。//by
-(void)tableView:(UITableView*)tableView提交的编辑样式:(UITableView单元格编辑样式)行的编辑样式索引路径:(nsindepath*)indepath

D_2。数据源删除一个数据

D_3。对数据源做些什么

D_4。[tableView relaodData]。//它正在主线程中工作

问题在于:

p_1。tableView无法滚动

p_2。tableView不执行任何委托方法

p_3。单元格中的视图不响应任何事件

我试试这个:

图1。将(D_4)
[tableView relaodData]
替换为
[tableView deleteRowsAtIndexPaths:@[indexPath]with RowAnimation:UITableViewRowAnimationNone]
。 没有问题,但我必须使tableView重新加载数据

图2。在aView中添加此代码:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *getView = [super hitTest:point withEvent:event];
debugLog(@"hit test get view : %@", getView);
return getView;
}
它可以正常观看。但这些观点没有回应任何事件

我认为在执行[tableView重载数据]时出现了一些问题。但是我找不到它

附加在:

  • tableView初始化:

    self.tableView                    = [UITableView new];
    self.tableView.dataSource         = self.tableDataSource;
    self.tableView.delegate           = self.tableDelegate;
    self.tableView.bounces            = NO;
    self.tableView.separatorStyle     = UITableViewCellSeparatorStyleNone;
    self.tableView.estimatedRowHeight = 55;
    self.tableView.rowHeight          = UITableViewAutomaticDimension;
    
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [ACellClass newWithParameters:...];
    }
    [cell clear];
    [self updateCell:cell withIndexPath:indexPath];
    return cell;
    }
    
  • 我将AView(AView.scrollView.tableView)作为自定义视图,tableView.delegate、tableView.dataSource是myController。该视图在
    [myController视图将显示:动画]
    中是新的

  • 删除带有委托的单元格:

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath {
       if (editingStyle == UITableViewCellEditingStyleDelete) {
         //delete data with index : indexPath.row.
         [tableView reloadData];
       }
     }
    
  • 我在D_3中做了一些数据操作


  • 您能否提供一些代码来说明:-如何初始化tableView-如何填充tableView-如何从数据源中删除数据-以及在这个步骤D_3上您在做什么。对数据源做些什么?我在底部添加信息。你在UISweepGestureRecognitor上做什么?你能提供代码吗?我搞错了,它看起来不是UISweepGestureRecognitor。我使用委托方法
    -(void)tableView:(UITableView*)tableView committedItingStyle:(UITableViewCellEditingStyle)editingStyle for RowAtIndexPath:(NSIndexPath*)indexPath
    删除一行。它不占用牢房的空间。我还尝试通过按钮删除一个数据,然后重新加载tableView。如果有什么方法可以解决这个问题,我宁愿用delegate方法删除数据。