Since Apple launched watchOS, it has been the watchOS 3 generation, so what can Apple Watch App bring to us? 1. Reminder function essential medicine for home travel 2. Exercise function 3. Call answering and other functions 5. SMS, wechat quick reply, well, I like this function 6. Rich dial application, want to change.

Open the Watch APP on iPhone and you can see the following interface

As you can see in the figure above, there are four main tabs. The first TAB is the UI for us to bind the watch, the second TAB is the personalized dial gallery, the third TAB is the App Store, and the fourth TAB is search TAB

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — gorgeous line — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

How does a developer go about creating an Apple Watch app step by step? Note (Development of WatchKit requires iOS 8.2 SDK and later.)

The first step is to create an Apple Watch project. The following figure,

Step 2: Create a project called WatchDemo:

We chose the popular swFIT language to build the demo, and we will use swFIT for the rest of the demo. After creating the demo, let’s look at our project directory structure:

It can be seen from the figure above that Watch App is divided into three modules. 2. WatchDemo WatchKit APP module, which is mainly responsible for the UI display of watch terminal. WatchDemo WatchKit Extension module This module is responsible for control Watch UI related WKInterfaceController–> understandable and UIViewController (but slightly different, explained later)

Let’s skip over the WKInterfaceController module first

import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
        
        // Configure interface objects here.
    }
    override func willActivate() {
        // This method is called when watch view controller is about to be visible to user
        super.willActivate()
    }
    override func didDeactivate() {
        // This method is called when watch view controller is no longer visible
        super.didDeactivate()
    }
}
Copy the code

Click the target button in the upper left corner as shown below:

The running effect is as follows:

What is WKInterfaceController? WKInterfaceController inherits NSObject not UIResponder, it doesn’t manage the Watch app, it manages the Watch app with WatchKit

WKInterfaceController also has a life cycle see the next section for details (Apple Watch WKInterfaceController).

##### want to know my dynamics at any time, welcome everyone to pay attention to my personal public number ant Farm home