Reputation: 280
I have a ViewController on which I can move multiple UIImageViews using gesture recognizers. it's working fine but the UIImageView selected is not on top of the others.
The UIImageViews keep the order of their creation so the last ones are always bellow the first ones.
Any advice?
Upvotes: 0
Views: 1256
Reputation: 2145
What you need to do it programmatically reorder them . You can do this in the following way
-(void)bringTheDesiredImageViewInFront:(int))_tagForImageView
{
for(UIImageView *_subView in self.view.subviews)
{
if([_subView isKindOfClass:[UIImageView class]])
{
UIImageView *temp=(UIImageView *)_subView;
if([temp tag]==_tagForImageView)
[self.view bringSubviewToFront:temp];
}
else
continue;
}
}
Call this method whenever the selector for any gestureRecognizer is called on any UIImageView . Also set the different tag values for different UIImageView . The above method could be called like this ,
UIImageView *imageView=[[UIImageView alloc] init];
[imageView setTag:1];
[self bringTheDesiredImageViewInFront:imageView.tag]
Upvotes: 0
Reputation: 88
You can use,
[superView bringSubviewToFront:touchedview];
for bringing the subview to the front
Upvotes: 0
Reputation: 1032
When you've selected your new UIImageView
- from your UIViewController
you should call:
[self.view bringSubviewToFront:imageView];
That should help.
Upvotes: 1