2010-08-13 47 views
0

我正試圖組合一個應用程序,該應用程序擁有一組隨機可用的文本,當用戶按下按鈕翻頁時。基本上,按下按鈕有兩件事,翻轉頁面並將文本更改爲隨機包含的短語。在iphone 4 sdk中,我如何獲得TransitionCurlUp觸發隨機文本?

我試圖通過讓頁面捲曲到相同的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]; 
} 

任何幫助將是如此之大。

+0

,如果你正確地格式化你的代碼可能有幫助... – 2010-08-16 22:39:51

+0

誒..哎呦對不起 – 2010-09-07 02:43:58

回答

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.... 
相關問題