2013-12-11 4 views
8

UITableViewでアイテムをタップすると、何もしなくても約3〜5秒後にUITableViewCellを押したままにしておくと、私は何をしたいのですか?iOS UITableViewCellアイテムを選択するのに長時間押さなければならない

は、ここに私のコード

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

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return 100; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    _cell = [_arrayItems objectAtIndex:indexPath.row]; 
    _cell = nil; 
    static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier"; 
    _cell = (CustomWidget *)[tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier]; 
    if (_cell == nil) { 
     _cell = [[CustomWidget alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier title:[_arrayItems objectAtIndex:indexPath.row] subTitle:@"Custom subtitle"]; 
    } 

    _cell.textLabel.text = [_arrayItems objectAtIndex:indexPath.row]; 
    _cell.textLabel.hidden = YES; 
    return _cell; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    return _arrayItems.count; 
} 


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; 
    _passedInPageTitle = selectedCell.textLabel.text; 
    [self openDetailPage]; 
} 
+0

CustomWidgetにUIButtonなどがあり、firstResponderになってそれらのイベントをすべて受け取っているのでしょうか?また、didSelectRowAtIndexPathの後に、私は通常 '[tableView deselectRowAtIndexPath:indexPath animated:YES];を呼び出して、選択解除状態になっていることを確認します。 – chuthan20

+1

didSelectRowAtIndexPathにブレークポイントを設定した場合、アイテムをタップすると2秒後にヒットしますか?3-5秒後ですか?無関係で、cellForRowAtIndexPathの最初の2行で何を達成していますか? –

+0

また、cellForRowAtIndexPathを直接呼び出すことはあまりお粗末ではありません。 indexPathを使用して、必要な情報をモデル(_arrayItems)から取得する必要があります。皆さんが知っている限り、それを呼び出すことは、メモリから全く新しい細胞を作り出すことかもしれません。 –

答えて

8

私は私の答えを見つけたhereだ - 私はタップをキャプチャしてUITableViewの親ビュー、上UITapGestureRecognizerを持っていました。

関連する問題