[Reprint]apple Watch Development Detailed

Source: Internet
Author: User

Apple Watch Development Detailed

Apple Watch is now more of an extra screen for third-party developers. The temporary WatchKit does not give enough interface. Now the main operational logic of the Watch app relies on Iphone,apple and promises to have a native watch app that might wait until the full version of Apple Watch and WatchKit is available.

1. Two kinds of screen resolution
Screen Size 38mm 42mm
Resolution 272 x 340 312 x 390
Width-to-height ratio 4:5 4:5
2, three kinds of screen modes
Main Screen mode Glance mode Notification Mode
Main interface Single Instant Information page Message Notification interface
Customizable layouts, placing controls such as buttons All information must be displayed in one screen, no interactive controls, click to enter Watch app Evoke when notified, can add appropriate buttons
3, two kinds of notification display mode
    • Two modes of display
Short Look Look
Long
View information on the screen that contains app icons, names, simple notifications, and more App icon and name will be moved to the top of the screen, the content occupies the main display space, the wearer can swipe to complete other interactions
    • Two modes of loading
Static Dynamic
Load directly into Load after initializing Interfacecontroller
4. Gestures

Supports only the following gestures and does not support custom gestures

gestures Behavior
Longitudinal slide Browse Content
Transverse slide Switch between pages
Tap Select content
Long Press Squeeze Open Menu
Digital crown Rotate, adjust the scrolling speed
Screen Edge Swipe left Back to previous interface
Swipe up at the bottom of the screen Open the Glance Interface
5. Watch APP Architecture
    • A completed Watch app consists of the WatchKit app and the WatchKit extension, WatchKit app is responsible for showing, installing on watch, WatchKit extension responsible for business and control logic, Installed on the iphone. All the arithmetic, logic, and control is done on the iphone. Communication via WatchKit

    • Watch App Control Flow

    • Viewcontroller life cycle

6. Basic class
    • Wkinterfacecontroller equivalent to Uiviewcontroller. The life cycle methods are:

      -initwithcontext: Called when initialized, the view element is typically configured here, which is equivalent to-viewdidload
      -willactivate is about to be rendered, or the view element is set in this method, which is equivalent to-viewwillappear
      -diddeactivate is called after rendering, and in this method the object holding self is deactivated, such as Nstimer. Equivalent to-viewdiddisappear

    • Wkinterfaceobject and its sub-categories

      Wkinterfaceobject is equivalent to UIView's proxy, WatchKit actually rendered view is invisible to the developer, and can only be set by Wkinterfaceobject the properties of the UI object, with very few properties to set. The cost of learning is not big.
      Wkinterfacebutton equivalent to UIButton agent
      Wkinterfaceimage equivalent to Uiimageview agent

WatchKit is independent of Uikit, and all classes inherit from NSObject, without a complete response chain

7. UI Development
  • Watch APP View development cannot use code, must StoryBoard.

  • The Watch app has a completely different layout than the IOS app. You cannot use AutoLayout or coordinates. Only relative layouts can be used.

    Level: Left center right
    Vertical: Top Center Bottom

  • The View size can be set in three different ways:

    Size to fit Content:view sizes to fit content

    Relative to Container: Set self size relative to container

    Fixed: set width and height

  • Wkinterfacegroup layout Container
    It seems that other Wkinterfaceobject subclass objects cannot overlap, and only this class can overlap with other wkinterfaceobject objects. The layout control equivalent to Android.

  • Wkinterfacetable List View

    You do not need to set delegate and datasource relative to UITableView. Set the number of rows and styles directly at initialization time.

    by-setnumberofrows:withrowtype:

    Set by-rowcontrolleratindex: Enumerate each row.

    The cell style is set by Rowcontroller, which is equivalent to UITableViewCell. Rowcontroller inherits from NSObject, which differs from other WK components. The display logic needs to be set in SB and bound. See the code in detail

    -(void) Table: (wkinterfacetable *) Table Didselectrowatindex: (nsinteger) RowIndex implement this method to accept the table's click Callback, Delegate is not required and cannot be set.

  • Menu View

    In SB, add the context Menu, long press the screen to exhale.

    Menu Item can be set in the form of SB or code. The context calls the following methods to add:

    -addmenuitemwithitemicon:title:action:
    -addmenuitemwithimagenamed:title:action:
    -addmenuitemwithimage:title:action:
    -clearallmenuitems

    In addition to using SB to set up and above methods, can not get wkinterfacemenu and Wkinterfacemenuitem instances or agents.

  • Wkinterfaceimage

    Equivalent to Uiimageview

    -setimagenamed: Get a picture of watch app, note that this image must be stored in the Watch app, in your own bundle. Images in extension are not displayed in this way.

    -setimage:-setimagedata: Get pictures from extension and transfer them to your watch via Bluetooth.

    The picture obtained in extension can be cached in the watch by Wkinterfacedevice's-addcachedimage:name: method. The cache size for each app is approximately 20M, and WatchKit will be removed from the oldest data to make room for new data.

8. Navigation Development
    • Stack navigation style, similar to Uinavigationcontroller. Touch the upper left corner to return

      -pushcontrollerwithname:context: The first parameter is the identifier string corresponding to the controller, which is set in SB. Data can be passed through content.

      -popcontroller

      -poptorootcontroller

    • Modal way. The behavior is basically the same as Uikit, the difference is that the upper left corner of the touch can return

      -presentcontrollerwithname:context:

      -dismisscontroller

    • Paging navigation. Similar to Uipagecontroller. Swipe left/right toggle

      -presentcontrollerwithnames:contexts: Incoming names and contexts arrays, the Controller that is exhaled in this way will be rendered in page navigation mode.

All navigation can be done in either code or SB's way.

9. Other
    • You cannot perform tasks that require permissions, such as requesting location permissions in watch
    • Do not perform background tasks in watch
    • Do not perform complex logic, time-consuming tasks in watch
    • Can't play video in Watch
    • Cache size Only 20M
    • Sensor API not open
    • Animation API is not open, with a set of frame pictures instead
10. Demo
      • Https://github.com/darcyzhang/CloudWatch

      • Requires more than xcode6.2 version to run

      • Choose iwatch WatchKit app to run

Original Blog Address: http://www.cnblogs.com/zy1987/articles/4352548.html

[Reprint]apple Watch Development Detailed

Related Article

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.