2013-12-11 14 views
8

Quindi questo mi sta facendo impazzire, ogni volta che tocchio un oggetto nel mio UITableView non fa nulla, ma quando tengo premuto UITableViewCell dopo circa 3-5 secondi, decide di andare avanti e fare ciò che voglio .. qualche pensiero perché questo potrebbe accadere?iOS UITableViewCell deve tenere premuto a lungo per selezionare l'articolo

Ecco il mio codice

- (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

Forse il vostro CustomWidget ha un UIButton o qualcosa di simile che divenne firstResponder e la ricezione di tutti quegli eventi? Inoltre, dopo didSelectRowAtIndexPath, di solito chiamo '[tableView deselectRowAtIndexPath: indexPath animato: YES];' per assicurarsi che venga deselezionato. – chuthan20

+1

Se si inserisce un breakpoint in didSelectRowAtIndexPath, viene colpito nel momento in cui si tocca un oggetto o dopo 3-5 secondi? Non correlato, cosa stai ottenendo con le prime due righe di cellForRowAtIndexPath? –

+0

Inoltre, chiamare direttamente cellForRowAtIndexPath non è molto kosher. È necessario recuperare le informazioni necessarie dal modello (_arrayItems) utilizzando indexPath. Per quel che ne sai, chiamarlo potrebbe creare una cella completamente nuova dalla memoria. –

risposta

8

ho trovato la mia risposta here - ho avuto una UITapGestureRecognizer sulla vista padre s' il UITableView, che è stato catturando il rubinetto.

Problemi correlati