The contents of the array become nil.

Asked 2 years ago, Updated 2 years ago, 32 views

That's how we put them together.However, when I run, image1~image6 appears as nil (there is an image called sample in the project).
I would appreciate it if you could tell me the cause.

let image1 = UIImage(named: "sample")
    let image2 = UIImage(named: "sample")
    let image3 = UIImage(named: "sample")
    let image4 = UIImage(named: "sample")
    let image5 = UIImage(named: "sample")
    let image6 = UIImage(named: "sample")

    let img = [image1!, image2!, image3!, image4!, image5!, image6!]

swift ios

2022-09-29 21:53

1 Answers

How about specifying an extension such as UIImage(named: "sample.png")

?

"Also, is ""Target Membership"" checked in the image file?"

Target Membership


2022-09-29 21:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.