1

I'm trying to change the background image of a WKInterfaceButton in my storyboard when a tap occurs. Also, on calling the setBackgroundImage to change the image, appendValue(1) does not work.

class keyPadInterfaceController : WKInterfaceController{
    @IBOutlet weak var OneClicked: WKInterfaceButton!
        let whiteImage = UIImage(named:"keybutton1.png")
        let goldImage = UIImage(named:"keybutton2.png")

    @IBAction func OneTapped(sender:AnyObject) {
        OneClicked.setBackgroundImage(goldImage)
        appendValue(1) 
    }
}
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
PS1690
  • 85
  • 8

1 Answers1

3

To access images using setBackgroundImage you must pass them from the users iPhone first.

Alternatively, you can use setBackgroundImageNamed. As a result, WatchKit checks your WatchKit app bundle first, followed by the device-side cache.

OneClicked.setBackgroundImageNamed("keybutton2.png")
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152