I am making an application that a user can upload from 1 to 3 photos. I want the user to be able to see them as a page control slider, I started to encode it, but for some reason the images are not added to scrollView (I don’t see anything when the application starts).
This is my code:
class dogProfileViewController: UIViewController {
var imagesArray = [UIImageView()]
@IBOutlet var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
let image1: UIImageView = UIImageView(image: UIImage(named: "image1.png"))
let image2: UIImageView = UIImageView(image: UIImage(named: "image2.png"))
imagesArray.append(image1)
imagesArray.append(image2)
var countIndex = CGFloat(0)
for image in imagesArray {
image.frame = CGRectMake(countIndex*view.frame.width, 0, view.frame.width, 100)
scrollView.addSubview(image)
countIndex = countIndex + 1
}
}
}
Eliko source
share