Watch OS 2 Issue to set an Image

2019-06-20 09:58发布

I just want to add an image to my WKInterfaceController but...

Xcode tells me :

Unable to find image named "circle44" on Watch

@IBOutlet var cirlceImage: WKInterfaceImage!
override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    cirlceImage.setImageNamed("circle44")
}

2条回答
倾城 Initia
2楼-- · 2019-06-20 10:40

Okay I found the result the image have to be in your WatchKt App not on your Extension. And with the addition of app thinning the watch no longer searches for 1x images as they should all be 2x. As you see in works !

import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {


    @IBOutlet var cirlceImage: WKInterfaceImage!

    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context)
        cirlceImage.setImageNamed("circle94")


    }

    override func willActivate() {
        super.willActivate()

    }

    override func didDeactivate() {
        super.didDeactivate()

    }
}
查看更多
Melony?
3楼-- · 2019-06-20 10:50

Add images into imagees.xcassets select Apple Watch then add 2x into there

enter image description here

查看更多
登录 后发表回答