J'ai ce code pour didSelectRowAtIndexPath, mais je veux optimiser le code pour créer un nouveau thread qui pousse un contrôleur de vue avec mes données d'un analyseur JSON.didSelectRowAtIndexPath pour appeler un nouveau thread
#pragma mark - DidselectRow
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//SPINNER
[spinner startAnimating];
//[self performSelector:@selector(pushDetailView:) withObject:tableView afterDelay:0.1];
/*
int *riga = indexPath.row;
[NSThread detachNewThreadSelector:@selector(pushDetailView) toTarget:self withObject:riga];
*/
NSLog(@"Seleziono l'immagine: %@", [photoTitles objectAtIndex:indexPath.row]);
//creo un'istanza di DettaglioView
DettaglioView *dettaglioImmagine = [[DettaglioView alloc] initWithNibName:@"DettaglioView" bundle:nil];
//Inseirsco il titolo nella Navigation BAR della vista
dettaglioImmagine.titoloSource = [photoTitles objectAtIndex:indexPath.row];
dettaglioImmagine.imageCoverSource = [photoURLsLargeImage objectAtIndex:indexPath.row];
NSLog(@"imageCoverSource: %@", dettaglioImmagine.imageCoverSource);
//passo alla vista del DettaglioView con l'animazione usando il pushViewController
[self.navigationController pushViewController:dettaglioImmagine animated:YES];
//pulisco lo style della cella selezionata togliendo il fondino blu
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//Attivo la vibrazione
[self buzz];
}
Maintenant, je souhaite faire une méthode externe de didSelectRowAtIndexPath pour pousser la vue détaillée comme ceci:
- (void)pushDetailView:(NSInteger *)idRow {
// Push the detail view here
}
Maintenant, mon problème est, comment puis-je passer le indexPath. méthode de ligne pour pousserDetailView?
J'ai essayer, mais ça ne marche pas
int *riga = indexPath.row;
[NSThread detachNewThreadSelector:@selector(pushDetailView) toTarget:self withObject:riga];
Bien Mais j'ai un problème avec mon "Spinne" qui est un indicateur UIActivity. – WalterFantauzzi
Eh bien, j'ai un problème à résoudre pour mon spinner qui est un UIActivityIndicator qui ne démarre pas lorsque l'utilisateur clique sur la cellule dans mon UITableview. J'ai défini dans mon init cette activitéIndicator spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge]; UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView: spinner]; [self navigationItem] .rightBarButtonItem = barButton; – WalterFantauzzi