Reputation: 101
I have checked UIImage works on the simulator but not working on the device. Here's the code:
imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
let image = UIImage(named: "sample.png")
imageView.image = image
view.addsubview(imageView)
How can I solve this problem?
Upvotes: 0
Views: 261
Reputation: 114
Extremely larger images bigger than UIImageView size causes the crash. UIImageView size is 50 x 50, but the image size is 900 x 900. This works on simulator but doesn't work on iOS device.
Upvotes: 3
Reputation: 1207
You need to add your image to 'Copy Bundle Resources'.
Select Target -> Build Phases -> Copy Bundle Resources and add your image to the list.
Upvotes: 0