rks*_*rst 5 iphone cocoa-touch objective-c
我在扩展UIView的类中有动画代码:
// 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];
Run Code Online (Sandbox Code Playgroud)
此动画代码适用于两个视图.但我试图为许多观点做这件事.我尝试添加一个全局变量(nextview index和currentView索引),但这不起作用,因为每个自定义视图类都有自己的实例,并且这些变量不共享.
有谁知道我怎么能完成我想做的事情?
谢谢!
编辑:如果我可以使用[self superview]访问当前视图和nextview的索引,我将能够这样做.有一些方法可以做到这一点吗?
归档时间: |
|
查看次数: |
22695 次 |
最近记录: |