2010-08-13 9 views
0

J'essaie de mettre en place une application qui a un ensemble de texte qui peut être aléatoire lorsque l'utilisateur appuie sur le bouton pour retourner la page. Fondamentalement, en appuyant sur le bouton fait deux choses; retourner la page et change le texte en une phrase incluse au hasard.Dans l'iphone 4 sdk, comment faire pour que TransitionCurlUp déclenche un texte aléatoire?

J'essaye d'implémenter ceci en faisant rouler la page dans le même fichier XIB et juste avoir le texte change. Le curl de la page fonctionne mais il ne change pas le texte. Je ne sais pas ce que je fais mal ici

Voici mon code:

@implementation InfoViewController 

@synthesize isViewPushed; 


// Implement viewDidLoad to do additional setup after loading the view. 
- (void)viewDidLoad { 


if(isViewPushed == NO) { 

{ UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btn.frame = CGRectMake(200, 300, 100, 50); 
[btn setTitle:@"Next" forState:UIControlStateNormal]; 
[btn addTarget:self action:@selector(cancel_Clicked:)  forControlEvents:UIControlEventTouchUpInside]; 
    [self.view addSubview:btn]; 
} 

{ UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btn.frame = CGRectMake(20, 300, 100, 50); 
[btn setTitle:@"Previous" forState:UIControlStateNormal]; 
[btn addTarget:self action:@selector(next_clicked:) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:btn]; 
} 

int text = rand() % 5; 
switch (text) { 
case 0: 
textview.text = @"Hello 1" ; 
break; 
case 1: 
textview.text = @"Hello 2" ; 
break; 
case 2: 
textview.text = @"Hello 3" ; 
break; 
case 3: 
textview.text = @"Hello 4" ; 
break; 
case 4: 
textview.text = @"Hello 5" ; 
break; 

} 
} 
} 


-(void) cancel_Clicked:(id)sender { 

[self.navigationController dismissModalViewControllerAnimated:YES]; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; 

[UIView commitAnimations]; 
} 

-(void) next_clicked:(id)sender { 


[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
[UIView commitAnimations]; 
} 

Toute aide serait si grand.

+0

Il peut être utile si vous formatez votre code correctement ... eh –

+0

oups .. . Désolé pour ça –

Répondre

0

Je ne vois pas où vous définissez la valeur de texte ici:

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 

...set or update text value here.... 

[UIView commitAnimations]; 

Ou après

[UIView commitAnimations]; 

...set or update text value here....