I have 20 UIImageView and i want change their image; but I don\'t want to create 20 IBOutlet, and I want to use tag value to change the image; I set the tag value in interface b
SWIFT, April 2015:
func createUIImageViews()
{
for i in 0...99
{
var imageView:UIImageView = UIImageView(frame: CGRectMake(CGFloat(0), CGFloat(0), CGFloat(100), CGFloat(100)))
imageView.userInteractionEnabled = true
imageView.tag = i
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "onImageViewTap:"))
self.view.addSubview(imageView)
}
}
func onImageViewTap(sender:UITapGestureRecognizer)
{
println("TAP: \(sender.view!.tag)")
}