Reputation: 283
I'm trying to animate a UIImage
and I have an UIImageView
called MainPic.
This is the code I am using:
@IBOutlet weak var MainPic: UIImageView!>
MainPic.animationImages = [
UIImage(named: "fox01")!,
UIImage(named: "fox02")!,
UIImage(named: "fox03")!,
UIImage(named: "fox04")!,
UIImage(named: "fox06")!
]
MainPic.animationDuration = 1
MainPic.startAnimating()
I made sure all the images were in the project. I've tried including them using the .jpg extension.
However, I am getting this error:
fatal error: unexpectedly found nil while unwrapping an Optional value
What is wrong with my code?
Upvotes: 2
Views: 2049
Reputation: 1053
There is ha two cases:
You can easily catch which item is nil, by simply printing all items before using. I can help more if you share more code or upload a simple example which reproducing your case.
Upvotes: 1