0

ユーザーがボタンを押してページをめくったときにランダム化できる一連のテキストを持つアプリをまとめようとしています。基本的に、ボタンを押すと 2 つのことが行われます。ページをめくってテキストをランダムに含まれるフレーズに変更します。

ページを同じ XIB ファイルにカールさせ、テキストを変更することで、これを実装しようとしています。ページカールは機能しますが、テキストは変更されません。ここで何が間違っているのかわかりません

これが私のコードです:

@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];
}

どんな助けでもとても素晴らしいでしょう。

4

1 に答える 1

0

ここでテキスト値を設定している場所がわかりません:

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

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

 [UIView commitAnimations];

またはその後

[UIView commitAnimations];

...set or update text value here....
于 2010-09-07T14:25:54.463 に答える