PDA

View Full Version : Swip many views




estupefactika
Mar 13, 2009, 06:08 AM
Hi, Im trying to swip many imageViews in a UIView


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (dirString)
{
CATransition *animation = [self getAnimation:dirString];
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
//[[self superview] exchangeSubviewAtIndex:currentView withSubviewAtIndex:newView];
[[[self superview] layer] addAnimation:animation forKey:kAnimationKey];

}
}


This animation code works fine for two subviews. But I am trying to do this for many subviews. I tried by adding a nextView index and currentView index, but nothing.

Example: I have 3 views with index 0, 1 and 2.
//First time, it works, it swips from Index View 2 to 1
[[self superview] exchangeSubviewAtIndex:2 withSubviewAtIndex:1];
//But here, it swips ever the same view with index 1, dont works
[[self superview] exchangeSubviewAtIndex:1 withSubviewAtIndex:0];

and it shoulds to swip after but it fail the previous swip:
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:2];

Any idea to swip several subviews? Thanks for your help