0

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?

4

3 回答 3

1

When you've selected your new UIImageView - from your UIViewController you should call:

[self.view bringSubviewToFront:imageView];

That should help.

于 2013-04-18T13:52:21.123 回答
0

You can use, [superView bringSubviewToFront:touchedview]; for bringing the subview to the front

于 2013-04-18T13:52:51.853 回答
0

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]
于 2013-04-18T14:01:38.790 回答