2014-01-22 25 views
0

我使用UiScrollSlidingPages(https://github.com/TomThorpe/UIScrollSlidingPages)插件,但我有一個問題。每個頁面的顯示視圖都是相同的,它是分配的最後一個視圖。UIScrollSlidingPages返回所有視圖相同的視圖(最後分配的視圖)

這是數據源委託的方法,該方法我使用

-(TTSlidingPage *)pageForSlidingPagesViewController:(TTScrollSlidingPagesController*)source atIndex:(int)index{ 

variabiliGlobali.paginaFormazione = index + 1; 
UIViewController *viewController; 
viewController = [[foaPaginaFormazioneVC alloc] init]; 
return [[TTSlidingPage alloc] initWithContentViewController:viewController]; 

} 

這是foaPaginaFormazioneVC代碼。

#import "foaPaginaFormazioneVC.h" 
#import "foaAppDelegate.h" 
#import "foaVotoCalciatoreCell.h" 
#import "foaBonusTotaliCell.h" 
#import "foaRiepilogoCell.h" 

@implementation foaPaginaFormazioneVC 

foaAppDelegate *variabiliGlobali; 

NSDictionary *formazione; 
NSDictionary *elencoCalciatori; 
NSDictionary *logFormazione; 
NSDictionary *logCalcolo; 

NSMutableArray *titolari; 
NSMutableArray *panchinari; 
NSMutableArray *logForTipo; 
NSMutableArray *logForValore; 
NSMutableArray *logCalTipo; 
NSMutableArray *logCalValore; 

bool calcolata; 


- (void)viewDidLoad 
{ 

    [super viewDidLoad]; 

    self.cellZoomInitialAlpha = [NSNumber numberWithFloat:1.0]; 
    self.cellZoomAnimationDuration = [NSNumber numberWithFloat:0.5]; 
    self.cellZoomXScaleFactor = [NSNumber numberWithFloat:0.9]; 
    self.cellZoomYScaleFactor = [NSNumber numberWithFloat:0.9]; 

    variabiliGlobali = (foaAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    formazione = [variabiliGlobali.formazioniA objectAtIndex: variabiliGlobali.paginaFormazione - 1]; 


    elencoCalciatori = [[NSDictionary alloc] init]; 
    logFormazione = [[NSDictionary alloc] init]; 
    logCalcolo = [[NSDictionary alloc] init]; 

    if ([formazione objectForKey:@"FORMAZIONE"] != [NSNull null]) { 
     elencoCalciatori = [formazione objectForKey:@"FORMAZIONE"]; 
    } 

    if ([formazione objectForKey:@"LOG_FORMAZIONE"] != [NSNull null]) { 
     logFormazione = [formazione objectForKey:@"LOG_FORMAZIONE"]; 
    } 

    if ([formazione objectForKey:@"LOG_CALCOLO"] != [NSNull null]) { 
     logCalcolo = [formazione objectForKey:@"LOG_CALCOLO"]; 
    } 


    titolari = [[NSMutableArray alloc] init]; 
    panchinari = [[NSMutableArray alloc] init]; 

    for (NSDictionary *dict in elencoCalciatori) { 
     if ([[dict objectForKey:@"ORDINE"] intValue] <= 11) { 
      [titolari addObject: dict]; 
     } 
     else { 
      [panchinari addObject: dict]; 
     } 

    } 

    logForTipo = [[NSMutableArray alloc] init]; 
    logForValore = [[NSMutableArray alloc] init]; 

    logCalTipo = [[NSMutableArray alloc] init]; 
    logCalValore = [[NSMutableArray alloc] init]; 

    NSString *appString; 
    bool appBool; 
    float appNumber; 

    if ([logFormazione count] != 0) { 
    //AMMINISTRATORE 
    appBool = [[logFormazione objectForKey:@"AMMINISTRATORE"] boolValue]; 
    if (appBool) { 
     [logForTipo addObject: @"Formazione inserita dall'amministratore"]; 
     [logForValore addObject: @""]; 
    } 

    //MODULO INIZIALE 
    appString = [logFormazione objectForKey:@"MODULO_INIZIALE"]; 
    [logForTipo addObject: @"Modulo Iniziale"]; 
    [logForValore addObject: appString]; 

    //DATA 
    appString = [logFormazione objectForKey:@"DATA"]; 
    [logForTipo addObject: @"Data Ultima Modifica"]; 
    [logForValore addObject: appString]; 
    } 

    if ([logCalcolo count] != 0) { 

    //MODULO FINALE 
    appString = [logCalcolo objectForKey:@"MODULO_FINALE"]; 
    [logForTipo addObject: @"Modulo Finale"]; 
    [logForValore addObject: appString]; 

    //PORTIERE IMBATTUTO 
    appNumber = [[logCalcolo objectForKey:@"PORTIERE_IMBATTUTO"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Portiere Imbattuto"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    //MOD_P 
    appNumber = [[logCalcolo objectForKey:@"MOD_P"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Modificatore Portiere"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    //MOD_D 
    appNumber = [[logCalcolo objectForKey:@"MOD_D"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Modificatore Difesa"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    //MOD_C 
    appNumber = [[logCalcolo objectForKey:@"MOD_C"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Modificatore Centrocampo"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    //MOD_A 
    appNumber = [[logCalcolo objectForKey:@"MOD_A"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Modificatore Attacco"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    //PUNTEGGIO 
    appNumber = [[logCalcolo objectForKey:@"PUNTEGGIO"] doubleValue]; 
    if (appNumber != 0) { 
     NSNumber *doubleNumber = [NSNumber numberWithDouble:appNumber]; 
     [logCalTipo addObject: @"Punteggio Finale"]; 
     [logCalValore addObject: [doubleNumber stringValue]]; 
    } 

    } 


} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    if (variabiliGlobali.gioCalcolata) { 
     return 4; 
    } 
    else { 
     return 3; 
    } 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

    NSInteger *numero; 

    //La giornata è calcolata. Sezione 2 = BONUS e TOTALI 
    if (variabiliGlobali.gioCalcolata && section == 2) { 
     numero = [logCalTipo count]; 
    } 

    //La giornata è calcolata. Sezione 3 = RIEPILOGO 
    //La giornata non è calcolata. Sezione 2 = RIEPILOGO 
    if ((variabiliGlobali.gioCalcolata && section == 3) || (variabiliGlobali.gioCalcolata == false && section == 2)) { 
     numero = [logForTipo count]; 
    } 



    if (section == 1) 
    {numero = [panchinari count];} 

    if (section == 0) 
    {numero = [titolari count];} 

    return numero; 


} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    NSString *idDettCal = @"cellaVotoCalciatore"; 
    NSString *idRiepilogo = @"riepilogoCell"; 
    NSString *idTotali = @"bonusTotaliCell"; 

    //Dictionary per Titolari e Panchinari 
    NSDictionary *calciatore; 




    if (indexPath.section == 0 || indexPath.section == 1) { 

     foaVotoCalciatoreCell *cell = (foaVotoCalciatoreCell *)[tableView dequeueReusableCellWithIdentifier:idDettCal]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idDettCal owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 
     } 


     //TITOLARI 
     if (indexPath.section == 0) { 
      calciatore = [titolari objectAtIndex:indexPath.row]; 

     } 
     //PANCHINARI 
     else if (indexPath.section == 1) { 
      calciatore = [panchinari objectAtIndex:indexPath.row]; 
     } 

     NSString *calciatoreStr = 
     [NSString stringWithFormat:@"%@%@%@%@", 
     [calciatore objectForKey:@"CALCIATORE"], 
     @" (", 
     [[calciatore objectForKey:@"SQUADRA"] substringToIndex:3], 
     @")"]; 


     NSString *imgRuolo = 
     [NSString stringWithFormat:@"%@%@", 
     [calciatore objectForKey:@"RUOLO"], 
     @".jpg"]; 

     cell.ruolo.image = [UIImage imageNamed:imgRuolo]; 


     NSDictionary *dettaglioVoto; 
     UIImageView *imageIcona; 
     CGFloat offset; 
     dettaglioVoto = [calciatore objectForKey:@"VOTO_STM"]; 

     offset = 0; 
     for (NSString *icona in dettaglioVoto) { 
      if ([icona isEqualToString: @"AMMONITO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"amm.png"]]; 
      } 
      else if ([icona isEqualToString: @"GOL_FATTO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golfatto.png"]]; 
      } 
      else if ([icona isEqualToString: @"GOL_SUBITO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golsubito.png"]]; 
      } 
      else if ([icona isEqualToString: @"ENTRATO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"entrato.png"]]; 
      } 
      else if ([icona isEqualToString: @"USCITO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uscito.png"]]; 
      } 
      else if ([icona isEqualToString: @"ESPULSO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"esp.png"]]; 
      } 
      else if ([icona isEqualToString: @"ASSIST"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"assist.png"]]; 
      } 
      else if ([icona isEqualToString: @"ASSIST_FERMO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"assistf.png"]]; 
      } 
      else if ([icona isEqualToString: @"RIGORE_SEGNATO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoresegnato.png"]]; 
      } 
      else if ([icona isEqualToString: @"RIGORE_SBAGLIATO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoresbagliato.png"]]; 
      } 
      else if ([icona isEqualToString: @"RIGORE_PARATO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rigoreparato.png"]]; 
      } 
      else if ([icona isEqualToString: @"AUTOGOL"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"autogol.png"]]; 
      } 
      else if ([icona isEqualToString: @"GOL_PARTITA"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golvittoria.png"]]; 
      } 
      else if ([icona isEqualToString: @"GOL_PAREGGIO"]) { 
       imageIcona = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"golpareggio.png"]]; 
      } 

      imageIcona.frame = CGRectMake(offset, 0, imageIcona.frame.size.width, imageIcona.frame.size.height); 
      //imageIcona.frame = CGRectMake(offset, 0, 20, 20); 
      offset = imageIcona.frame.size.width + offset + 2; 
      [cell.iconeDettaglio addSubview: imageIcona]; 
     } 

     if (offset == 0) { 
      //cell.calciatore.frame = CGRectMake(cell.calciatore.frame.origin.x, 14, cell.calciatore.frame.size.width, cell.calciatore.frame.size.height); 
     } 

     cell.calciatore.text = calciatoreStr; 
     cell.votoIniziale.text = [calciatore objectForKey:@"VOTO_PRNT"]; 
     cell.votoFinale.text = [calciatore objectForKey:@"VOTO_PRNT_TOT"]; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 

    } 
    //La giornata è calcolata. Sezione 2 = BONUS e TOTALI 
    else if (variabiliGlobali.gioCalcolata && indexPath.section == 2) { 

     NSDictionary *totaliVal; 
     NSDictionary *totaliTip; 

     totaliVal = [logCalValore objectAtIndex:indexPath.row]; 
     totaliTip = [logCalTipo objectAtIndex:indexPath.row]; 

     foaBonusTotaliCell *cell = (foaBonusTotaliCell *)[tableView dequeueReusableCellWithIdentifier:idTotali]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idTotali owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 
     } 

     cell.tipoBonusLabel.text = totaliTip; 
     cell.totaleLabel.text = totaliVal; 

     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 

    } 

    //La giornata è calcolata. Sezione 3 = RIEPILOGO 
    //La giornata non è calcolata. Sezione 2 = RIEPILOGO 
    //else ((variabiliGlobali.gioCalcolata && indexPath.section == 3) || 
    //  (variabiliGlobali.gioCalcolata == false && indexPath.section == 2)) { 

    //} 

    else { 
     NSDictionary *riepilogoVal; 
     NSDictionary *riepilogoTip; 

     riepilogoVal = [logForValore objectAtIndex:indexPath.row]; 
     riepilogoTip = [logForTipo objectAtIndex:indexPath.row]; 

     foaRiepilogoCell *cell = (foaRiepilogoCell *)[tableView dequeueReusableCellWithIdentifier:idRiepilogo]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:idRiepilogo owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 
     } 

     cell.voceRiepilogoLabel.text = riepilogoTip; 
     cell.valoreRiepilogoLabel.text = riepilogoVal; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 
    } 



} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 

    NSString *header; 

    if (variabiliGlobali.gioCalcolata && section == 2) { 
     header = @"Bonus e Totale"; 
    } 

    if ((variabiliGlobali.gioCalcolata && section == 3) || (variabiliGlobali.gioCalcolata == false && section == 2)) { 
     header = @"Riepilogo"; 
    } 



    if (section == 1) 
    {header = @"Panchinari";} 

    if (section == 0) 
    {header = @"Titolari";} 

    return header; 

} 


@end 

如果我使用另一個簡單的視圖(只有一個隨機標籤)插件工作正常。

這是怎麼回事?

在此先感謝。

回答

0

我已經解決了我的問題在視圖控制器的.h文件聲明這些變量

NSDictionary *formazione; 
NSDictionary *elencoCalciatori; 
NSDictionary *logFormazione; 
NSDictionary *logCalcolo; 

NSMutableArray *titolari; 
NSMutableArray *panchinari; 
NSMutableArray *logForTipo; 
NSMutableArray *logForValore; 
NSMutableArray *logCalTipo; 
NSMutableArray *logCalValore; 

bool calcolata; 

相關問題