I have animation code in a class that extends the 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];
This animation code works fine for two views. But I am trying to do this for many views. I tried by adding in a global variable (nextview index and currentView index), however this doesn't work since each custom view class has it's own instance and these variables aren't shared.
Does anyone know how I can accomplish what I want to do?
Thanks!
Edit: I would be able to do this, if I could use [self superview] to access the index of the currentview and of the nextview. Are there some methods to do this?