views:

28

answers:

1

Hello friends

I am trying to put together an app that has a set of text that can be randomized when the user presses the button to flip the page. Basically, pressing the button does two things; flip the page and changes the text to a randomly included phrase.

I am trying to implement this by having the page curl into the same XIB file and just have the text change. The page curl works but it is not changing the text. Not sure what I am doing wrong here

Here is my 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];
}

Any help would be so great.

A: 

I don't see where you are setting the text value here:

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

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

 [UIView commitAnimations];

Or after

[UIView commitAnimations];

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