ios - Apple watch not showing any images -
we having problems image not showing on apple watch, tried following :
our image located in apple watchkit extension, , tried put in cache:
let img = uiimage(named:"slider_r.png") wkinterfacedevice().addcachedimage(img!, name:"slider_r.png") it crashed immediately...
then tried add image directly on apple watchkit app: no assets. no image loaded up...
then tried putting in image.assets didn't work either... out of ideas...
thanks !
alright, i've been working watchkit month - here's know:
- placing image watch app's assets catalog add watch's bundle. available use using uiimage's
.setimagenamed("name"). - placing image watch extension's assets catalog add extension's bundle, residing on phone. now, watch have first grab reference image from extension, add device's cache, using
wkinterfacedevice().addcachedimage(image, name:).
check out apple documentation providing images watch here. here's documentation setimage(_ image: uiimage?):
this method changes image being displayed. use method send images watchkit extension watchkit app. image interface object resized accommodate size of newly specified image. if image large device’s screen, image clipped.
this not want. want explicitly add image cache can use later. if use setimage described above, transfer image phone watch every time call it, not ideal if you're using same image in multiple locations or you're using frequently. have careful in choosing images want cache on watch.
using know:
var img: uiimage = uiimage(named: "slider_r") // grabs image extension's bundle wkinterfacedevice().addcachedimage(img!, named: "slider_r") // adds watch cache myimageoutlet.setimagenamed("slider_r") // grabs image watch cache - ensure asset catalog included in extension's target images correctly placed in bundle @ runtime.
- you not need include extension (e.g. ".png") in image's name.
Comments
Post a Comment