我已經爲didSelectRowAtIndexPath這個代碼,但我想優化代碼,使一個新的線程,推動視圖控制器從我的數據從JSON解析器。didSelectRowAtIndexPath調用新的線程
#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];
}
現在,我想做出推從didSelectRowAtIndexPath方法的外部方法類似這樣的細節視圖:
- (void)pushDetailView:(NSInteger *)idRow {
// Push the detail view here
}
現在我的問題是,如何才能通過indexPath。行方法pushDetailView?
我已經嘗試這一點,但它不工作
int *riga = indexPath.row;
[NSThread detachNewThreadSelector:@selector(pushDetailView) toTarget:self withObject:riga];
嗯但我有一個問題,我的「Spinne」是一個UIActivityIndicator。 – WalterFantauzzi 2012-03-02 08:40:00
嗯,我有一個問題需要解決,因爲我的微調是一個UIActivityIndicator,當用戶點擊我的UITableview中的單元格時無法啓動。 我已經在我的init中定義了這個activityIndicator spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:spinner]; [self navigationItem] .rightBarButtonItem = barButton; – WalterFantauzzi 2012-03-02 08:42:56