My first Apple Watch application--hello watch__apple

Source: Internet
Author: User

Today let's create one of the simplest Apple Watch programs and implement the simplest response. The Xcode version is 7. Implemented as follows:

(1) To create a watchOS application:


(2) Note that the following "include Glance Scene" should be selected. As shown in figure:


(3) As with iOS development, we can also drag controls directly, and in interface controller drag the controls as follows:

(4) through the Segue line, the implementation of the code in the Interfacecontroller.swift is as follows:

Import watchkit
Import Foundation


class Interfacecontroller:wkinterfacecontroller {

  
  
  @IBOutlet var mylabel:wkinterfacelabel!
  
  
  
    Override func Awakewithcontext (Context:anyobject?) {
        Super.awakewithcontext (context)
        
        //Configure interface objects here.
    }

    Override Func Willactivate () {
        //This method was called when watch View Controller are about to are visible to user
        Super.willactivate ()
    }

    override Func Diddeactivate () {
        //This method was called when watch View Controller is no longer visible
        super.diddeactivate ()
    }

  
  @IBAction func btnclicked () {
    
    Mylabel.settext (" 111111 ")
    
  }
}

(5) The running program is as follows: by clicking the button, you can change the text in the label below;



(6) Of course, we can also design the interface in the glance, by clicking on the control in the glance, you can click into the app;


.


GitHub home: https://github.com/chenyufeng1991. You are welcome to visit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.