I want to load an array of images before the app show its views to user, with a custom delay for example 5 milliseconds . any help ??
I've used UIImageView in UIViewController and this is my code:
import UIKit
class CustomViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
var logoImage: [UIImage] = [
UIImage(named: "splash_logo_1.png")!,
UIImage(named: "splash_logo_2.png")!,
UIImage(named: "splash_logo_3.png")!,
UIImage(named: "splash_logo_4.png")!,
UIImage(named: "splash_logo_5.png")!,
UIImage(named: "splash_logo_6.png")!,
UIImage(named: "splash_logo_7.png")!,
UIImage(named: "splash_logo_8.png")!,
UIImage(named: "splash_logo_9.png")!,
]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8 , execute: {
// Put your code which should be executed with a delay here
for i in 1..<self.logoImage.count
{
let image = self.logoImage[i]
self.imageView.image = image
}
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
after building the app, it only shows the last image (plash_logo_9.png).
so where is the problem ..?