2011-11-01 180 views
1

我試圖用UIViewAnimationTransitionCurlUp在兩個視圖之間進行轉換。 我的應用程序在橫向(左和右)工作,我需要從右向左轉換。 UIViewAnimationTransitionCurlUp從下往上(而不是從右到左,因爲我想)。 我的第一個版本是:UIViewAnimationTransitionCurlUp從橫向(左和右)方向從右到左

self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease]; 
self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease]; 
[self.view addSubview:self.oneView]; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; 
[self.oneView removeFromSuperview]; 
[self.view addSubview:twoView]; 
[UIView commitAnimations]; 

它的工作景觀帶回家鍵,右側(過渡是從右到左開始與右上角如需要)。 但是,當設備旋轉到左側的home按鈕時,捲曲效果是顛倒的:從左到右以左角開始)。 動畫似乎並不知道設備的方向。 我爲了使用中間容器視圖(self.view和

self.oneView/twoView): 
self.containerView = [[[UIView alloc] initWithFrame:frame] autorelease]; 
self.oneView = [[[UIImageView alloc] initWithFrame:frame] autorelease]; 

self.twoView = [[[UIImageView alloc] initWithFrame:frame] autorelease]; 
[self.view addSubview:self.containerView]; 
[self.containerView addSubview:self.oneView] 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES]; 
[self.oneView removeFromSuperview]; 
[self.containerView addSubview:twoView]; 
[UIView commitAnimations]; 

之間改變代碼現在它意識到裝置旋轉並工作正常兩個橫向。 但是,從下到上工作(已啓動。與右下角),因爲它在文檔中描述 但我希望它由右至左的工作 我還試圖用變換的觀點就像性質:

self.containerView.transform = CGAffineTransformMakeRotation(-M_PI_2); 
self.oneView.transform = CGAffineTransformMakeRotation(M_PI_2); 

它並沒有幫助 所以,一個問題是: 如何在橫向模式(左側和右側)中使用過渡UIViewAnimationTransitionCurlUp在從右到左的視圖之間進行過渡? 感謝您的幫助! Alex

+0

你可以從右向左轉換嗎? – Beto

回答

0

您是否嘗試過使用UIViewAnimationTransitionCurlDown?這是UIViewAnimationTransitionCurlUp的相反方向。

+0

是的,實際上我使用UIViewAnimationTransitionCurlUp和UIViewAnimationTransitionCurlDown在幾個圖像之間向前和向後移動。我只是簡化了問題的描述,避免了無關的事情。 – ashumilov