Watch OS 2 Issue to set an Image

橙三吉。 提交于 2019-12-10 13:27:37

问题


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")
}

回答1:


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.

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()

    }
}



回答2:


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



来源:https://stackoverflow.com/questions/32281009/watch-os-2-issue-to-set-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!