Matte.Car
Matte.Car

Reputation: 2027

Trouble displaying an Image on  Watch

I need to display an image in a  Watch app. Initially I was using imageView.setImageNamed("us") and it was good.

Now I need to manipulate the image so I need to create an instance of the image, then manipulate and display it. To make an instance (a copy) of the image I use let image = UIImage(named: "us")! but it returns nil and I can't understand the reason... Does someone know why?

EDIT: Here's an example project.

Upvotes: 0

Views: 75

Answers (1)

Dmytro Hutsuliak
Dmytro Hutsuliak

Reputation: 1751

The problem is in Assets. If you use a unique Assets for iPhone and Watch that's how to set "Target Membership":

  • Using imageView.setImageNamed("us"), the image is managed directly from a storyboard so you need to set the target to WatchKit App (graphic part of Watch App).

  • Using let image = UIImage(named: "us")!, the image is managed programmatically from an interface controller so you need to set a target to WatchKit Extension (code part of Watch App).

enter image description here

Upvotes: 1

Related Questions