我有一個擴展的UIView類動畫代碼:如何做兩個以上的UIViews之間的翻轉動畫?
// Start Animation Block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
//int nextView = currentView + 1;
// Animations
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
//And so I would do: [[self superview exchangeSubviewAtIndex:currentView withSubviewAtIndex:nextView];
//Doesn't work because curentView is not global... with each instance of a class it's reset to what it's instanciated to.
//currentView++;
// Commit Animation Block
[UIView commitAnimations];
這個動畫代碼工作正常兩種觀點。但我試圖爲很多觀點做到這一點。我嘗試通過添加一個全局變量(nextview index和currentView index),但是這不起作用,因爲每個自定義視圖類都有它自己的實例,並且這些變量不被共享。
有誰知道我該如何完成我想要做的事情?
謝謝!
編輯:我可以做到這一點,如果我可以使用[self superview]來訪問currentview和nextview的索引。有沒有一些方法可以做到這一點?
我有意見的數組,我創建appdelegate和我添加一個不同的數組到每個標籤視圖控制器。然後控制器使用該數組創建動畫uiviews以在它們之間切換。我在動畫切換時遇到了問題... – rksprst 2008-10-26 21:45:14