单击时未调用UITableView didSelectRowatIndexPath

非常奇怪! 它适用于所有地方但在这里

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MyViewController* cliente = [[MyViewController alloc] initWithModeAndClientId:2 c:cid]; cliente.delegate = self; UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:cliente]; n.navigationBarHidden = NO; [[n navigationBar] setBarStyle:UIBarStyleBlack]; [self presentViewController:n animated:YES completion:nil]; } 

如果我点击该行点击, MyViewController在几秒钟后显示! 如果我点击两次,它会迅速显示! 在Profiler中,单击没有任何反应……我没有didDeselectRowAtIndexPath方法。

解决方案是在主线程上加载第二个控制器

  dispatch_async(dispatch_get_main_queue(), ^{ // Code here }); 

它的线程问题,当您在tableview中点击一行时,它会启动一个新线程,因此呈现视图可能需要更长时间才能显示在屏幕上。

解决方案是:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { dispatch_async(dispatch_get_main_queue(), ^{ MyViewController* cliente = [[MyViewController alloc] initWithModeAndClientId:2 c:cid]; cliente.delegate = self; UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:cliente]; n.navigationBarHidden = NO; [[n navigationBar] setBarStyle:UIBarStyleBlack]; [self presentViewController:n animated:YES completion:nil]; }); } 

你是否有机会在滚动视图中放置一个tableview? 如果是这样,容器scrollview阻止触摸事件到内部表视图。 这为我修好了:

 self.myContainerScrollview.panGestureRecognizer.delaysTouchesBegan = true 

答案应该归功于OP: https : //stackoverflow.com/a/31040918/1455770

有同样的问题。 而且很难找到。 但这是因为以下原因:

 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { return nil; } 

您应该返回indexPath