I have a image wall (UIScrollView
) and in there I have a lot of UIImageView's
.
Here is my code:
for (ThumbPosterModel *tPoster in _thumbsPosterStack) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:tPoster.thumb];
imageView.userInteractionEnabled = YES;
imageView.frame = CGRectMake(i, imageView.frame.origin.y, imageView.frame.size.width, imageView.frame.size.height);
[tPoster setTag:tag];
[_posterTagArr addObject:(BasicPosterModel*)tPoster];
imageView.tag = tag;
tag++;
[posterWallScrollView addSubview:imageView];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageDoubleTapped:)];
doubleTap.numberOfTapsRequired = 2;
[imageView addGestureRecognizer:doubleTap];
}
And Here is my IBAction:
-(IBAction)imageDoubleTapped:(id)sender {
NSInteger selectTag = (((UIGestureRecognizer*)sender).view.tag);
for (BasicPosterModel *bPoster in _posterTagArr) {
if(bPoster.tag == selectTag) {
[UIView transitionFromView:(UIImageView*)((UIGestureRecognizer*)sender).view
toView:mySecordView //let's say next ImageView. Doesn't matter
duration:1.0
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished) {
// animation completed
}];
}
}
}
And when I use:
UIViewAnimationOptionTransitionCrossDissolve
this is effect ONLY on my image in ScrollView.
When I use in this code UIViewAnimationOptionTransitionFlipFromTop
this affect to my scrollView.
How it's possible?
Of course I want to my Animation effect only for single image.
Here's how the transition works conceptually:
In your case the parent view is the scroll view, so the whole scroll view is transitioned. Counter to your perception, that's the case even when using a cross dissolve. It's just that most of the scrollview (the part that's not covered by fromView) is identical before and after, so it looks as if that part does not take part in the transition - but it does.
If I understand correctly, your are arranging multiple stacks of image views horizontally in your scroll view, and whenever someone double taps on the "uppermost" image view in a stack, you want to "reveal" the image directly below it, without affecting the other stacks.
If you add a container view to the scrollView for each of these stacks that is the same size as the stack, and put all the ImageViews for this stack into this container view instead of directly into the scroll view, it will work. On tap, just do a transition from the tapped view to nil as you originally did. The transition's size on the screen will be limited to the container view (roughly - curls and flips use some space beyond its frame).
Depending on your requirements, you might want to remove the stack's container view after the last image in the stack is removed.
The reason is that UIViewAnimationOptionTransitionFlipFromTop
is only availavle since iOS 5.0
From UIView Class Reference :
UIViewAnimationOptionTransitionFlipFromTop
A transition that flips a view around its horizontal axis from top to bottom. The top side of the view moves toward the front and the bottom side toward the back.
Available in iOS 5.0 and later.
Declared in UIView.h.`
So, in iOS 4.3 it may cause unpredictable behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With