0

I'm trying to compare two images that is stored as an array of UIImageView.

How can I access a particular image through a tag?

EDIT: If images were stored as separate UIImageView I would have compared

imageView1.image == imageView2.image;

But since it is stored as an array I'm confused to access it. Ideally it would be

someArray[1].image == someArray[2].image;

But it is not viable.

JannaBotna
  • 27
  • 8

1 Answers1

0
UIImageView *imageView = (UIImageView*)[self.view viewWithTag:someTag];

Just send viewWithTag to any instance of UIView and you'll get the View with that tag back.

David Xu
  • 5,555
  • 3
  • 28
  • 50
  • Point of clarification: Not any UIView, but any superview of the view in question. (or super-super view, etc.) It won't work if the UIView you query is a sibling of your image view. – Duncan C Jan 17 '15 at 22:11
  • David, remember that lots of total newbies read SO. You shouldn't make any statements that can be misinterpreted due to a lack of prior knowledge. Even if the OP gets it, the 50 other newbies who read the thread won't. – Duncan C Jan 17 '15 at 23:59
  • I'm Not knocking newbies either. We were all beginners once. (Of course there was no such thing as the internet when I was a newbie, but that's a different story.) – Duncan C Jan 18 '15 at 00:00