【问题标题】:didSelectRowAtIndexPath called only with long press on a tableView embedded in a container viewdidSelectRowAtIndexPath 仅通过长按嵌入在容器视图中的 tableView 调用
【发布时间】:2014-06-15 17:40:55
【问题描述】:

我在 containerView 中有一个 UItableViewController,当我触摸其中一个单元格时,它不会调用 didSelectRowAtIndexPath。但是,如果我长按,这个方法是正常调用的。

我用过storyboard,我的delegatedatasource 是我的tableViewController

这是我的 tableViewController 代码:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return nuberOfSections;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return nuberOfSections;  
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return heightForHeader;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MWSideMenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"menuCell"];
    // cell settups
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    // Some action done
}

【问题讨论】:

  • 您是否在任何视图中使用任何手势识别器?
  • 你确定你没有实现didDESelect...而不是didSelect...
  • 我遇到了同样的问题,你对此有什么结论吗?
  • 我刚刚遇到了这个问题,发现我在容器视图控制器上设置了一个点击手势识别器来关闭键盘。检查你是否有同样的问题。

标签: ios objective-c uitableview uicontainerview


【解决方案1】:

同样的问题发生在我身上,因为我在它上面添加了一个点击手势识别器。 `

如果您使用过任何手势,请尝试将其移除

` 并检查它是否导致问题。

【讨论】:

    【解决方案2】:

    可能有三个原因

    1. 未设置委托
    2. 可能是 didselectrowatindexpath 中的拼写错误
    3. 手势识别器可能用于容器 VC 或包含 VC 中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-15
      • 2018-01-18
      • 1970-01-01
      • 2016-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多