2013-11-22 67 views
2

非常奇怪!它的工作原理無處不在,但在這裏: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節目挖掘! 如果我點擊兩次,它顯示很快! 在分析器中,單擊時沒有任何反應... 我沒有didDeselectRowAtIndexPath方法。

+0

你有你的細胞可能被捕捉龍頭頂部的任何手勢識別器或意見? –

+0

沒有人......如果我使用[[self navigationController] pushViewControllerRetro:schedaCliente]; – giuseppe

+0

你的視圖控制器初始化代碼是否被阻塞?使用儀器 - >時間分析器來查看你的代碼是否需要很長時間。 –

回答

3

解決的辦法是把主線程加載第二控制器

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

你收到tableView:didDeselectRowAtIndexPath:在不同的線程比主要? –

+0

不,因爲我說我沒有使用任何didDeselectRow。 – giuseppe

+0

對不起,我的意思是tableView:didSelectRowAtIndexPath :.我只是想看看爲什麼dispatch_async使這個工作。或者它是與線程或動畫有關的。 –

2

它的線程的問題,當你點擊在實現代碼如下一行就開始一個新的線程,這樣的呈現視圖可能需要更長時間顯示在屏幕上。

解決的辦法是:

- (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]; 
    }); 
} 
0

任何機會把一個tableview中滾動視圖裏面是嗎?如果是這樣,容器滾動視圖將觸摸事件阻塞到內部表格視圖。這個固定爲我:

self.myContainerScrollview.panGestureRecognizer.delaysTouchesBegan = true 

信貸的答案應該去這裏的OP:https://stackoverflow.com/a/31040918/1455770

0

有同樣的問題。而且很難找到。但是,這是因爲以下幾點:

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

您應該返回indexPath

相關問題