diff --git a/README.md b/README.md index 6f2c4c4..5339950 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Contact](https://img.shields.io/badge/contact-wangyanchang21-green.svg)](https://github.com/wangyanchang21) -A comprehensive tutorial app for WatchOS, in swift. +A nice tutorial app for WatchOS, in swift. Watch-App-Sampler has supported WatchOS 5.0 and Swift 4.2. @@ -59,6 +59,14 @@ Menus and actions. ![](https://github.com/wangyanchang21/Watch-App-Sampler/blob/master/image/menum.gif) + +### GestureRecognizer + +The type of Gesture, including TapGesture, LongPressGesture, SwipeGesture, PanGesture + +![](https://github.com/wangyanchang21/Watch-App-Sampler/blob/master/image/gesture.gif) + + ### Alert Three alert style and AlertAction. diff --git a/Watch-App-Sampler WatchKit App/Base.lproj/Interface.storyboard b/Watch-App-Sampler WatchKit App/Base.lproj/Interface.storyboard index 04fea31..f0674ee 100644 --- a/Watch-App-Sampler WatchKit App/Base.lproj/Interface.storyboard +++ b/Watch-App-Sampler WatchKit App/Base.lproj/Interface.storyboard @@ -1034,5 +1034,61 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Watch-App-Sampler WatchKit Extension/DemoController/GestureRecognizerController.swift b/Watch-App-Sampler WatchKit Extension/DemoController/GestureRecognizerController.swift new file mode 100644 index 0000000..dfdf14e --- /dev/null +++ b/Watch-App-Sampler WatchKit Extension/DemoController/GestureRecognizerController.swift @@ -0,0 +1,35 @@ +// +// GestureRecongnizerController.swift +// Watch-App-Sampler WatchKit Extension +// +// Created by DCSnail on 2019/2/20. +// Copyright © 2019 DCSnail. All rights reserved. +// + +import UIKit +import WatchKit + +class GestureRecognizerController: WKInterfaceController { + + @IBOutlet var tapLabel: WKInterfaceLabel! + @IBOutlet var longPressLabel: WKInterfaceLabel! + @IBOutlet var swipeLabel: WKInterfaceLabel! + @IBOutlet var panLabel: WKInterfaceLabel! + + + @IBAction func tapAction(_ sender: Any) { + tapLabel.setText("Taped!") + } + + @IBAction func longPressAction(_ sender: Any) { + longPressLabel.setText("Long Pressed!") + } + + @IBAction func swipeAction(_ sender: Any) { + swipeLabel.setText("Swiped!") + } + + @IBAction func panAction(_ sender: Any) { + panLabel.setText("Panned!") + } +} diff --git a/Watch-App-Sampler WatchKit Extension/ItemListController.swift b/Watch-App-Sampler WatchKit Extension/ItemListController.swift index 88822eb..32ef59b 100644 --- a/Watch-App-Sampler WatchKit Extension/ItemListController.swift +++ b/Watch-App-Sampler WatchKit Extension/ItemListController.swift @@ -20,6 +20,7 @@ class ItemListController: WKInterfaceController { return [ ["image": "item_type_0", "title": "Menu Action And Controller Life Cycle" , "ID": "MenusController"], + ["image": "item_type_1", "title": "Gesture Recongnizer" , "ID": "GestureRecongnizerController"], ["image": "item_type_2", "title": "Alert Style" , "ID": "AlertController"], // Picker ["image": "item_type_3", "title": "Picker Styles" , "ID": "PickerController"], diff --git a/Watch-App-Sampler.xcodeproj/project.pbxproj b/Watch-App-Sampler.xcodeproj/project.pbxproj index 10c7ad2..d2c0c1f 100644 --- a/Watch-App-Sampler.xcodeproj/project.pbxproj +++ b/Watch-App-Sampler.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 5F2AA6B720D3C31500D0DE5D /* RecordController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F2AA6B620D3C31500D0DE5D /* RecordController.swift */; }; 5F3FB9122200427100F30007 /* loading.gif in Resources */ = {isa = PBXBuildFile; fileRef = 5F3FB9112200427000F30007 /* loading.gif */; }; 5F55F884221D655900323342 /* AudioFilePlayerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F55F883221D655900323342 /* AudioFilePlayerController.swift */; }; + 5F55F886221D810B00323342 /* GestureRecognizerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F55F885221D810B00323342 /* GestureRecognizerController.swift */; }; 5F6C763520E4BC10006DEA42 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5F2AA68B20D3ABF700D0DE5D /* Assets.xcassets */; }; 5F6C763720E4CFDD006DEA42 /* AlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F6C763620E4CFDD006DEA42 /* AlertController.swift */; }; 5F76440120D91669003AB207 /* MessageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F76440020D91669003AB207 /* MessageController.swift */; }; @@ -131,6 +132,7 @@ 5F2AA6B620D3C31500D0DE5D /* RecordController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordController.swift; sourceTree = ""; }; 5F3FB9112200427000F30007 /* loading.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = loading.gif; sourceTree = ""; }; 5F55F883221D655900323342 /* AudioFilePlayerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioFilePlayerController.swift; sourceTree = ""; }; + 5F55F885221D810B00323342 /* GestureRecognizerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GestureRecognizerController.swift; sourceTree = ""; }; 5F680FBC20F714B2001E0434 /* Watch-App-Sampler WatchKit Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Watch-App-Sampler WatchKit Extension.entitlements"; sourceTree = ""; }; 5F6C763620E4CFDD006DEA42 /* AlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertController.swift; sourceTree = ""; }; 5F76440020D91669003AB207 /* MessageController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageController.swift; sourceTree = ""; }; @@ -259,6 +261,7 @@ isa = PBXGroup; children = ( 5F76440A20DA62A7003AB207 /* MenusController.swift */, + 5F55F885221D810B00323342 /* GestureRecognizerController.swift */, 5F6C763620E4CFDD006DEA42 /* AlertController.swift */, 5FD7890820DBB4E100381EFE /* PickerController.swift */, 5F2AA6B020D3BFCA00D0DE5D /* ProgressController.swift */, @@ -508,6 +511,7 @@ 5F2AA6B520D3C25D00D0DE5D /* TextVoiceInputController.swift in Sources */, 5FF489C0213E74360082DB20 /* KeychainHelper.swift in Sources */, 5F55F884221D655900323342 /* AudioFilePlayerController.swift in Sources */, + 5F55F886221D810B00323342 /* GestureRecognizerController.swift in Sources */, 5FD7890F20DCF56C00381EFE /* HapticTypeController.swift in Sources */, 5F2AA6AD20D3BF2F00D0DE5D /* ComplicationController.swift in Sources */, 5FD7890D20DCE02100381EFE /* AnimationController.swift in Sources */, diff --git a/Watch-App-Sampler.xcodeproj/project.xcworkspace/xcuserdata/dcsnail.xcuserdatad/UserInterfaceState.xcuserstate b/Watch-App-Sampler.xcodeproj/project.xcworkspace/xcuserdata/dcsnail.xcuserdatad/UserInterfaceState.xcuserstate index 7a2193b..f170d33 100644 Binary files a/Watch-App-Sampler.xcodeproj/project.xcworkspace/xcuserdata/dcsnail.xcuserdatad/UserInterfaceState.xcuserstate and b/Watch-App-Sampler.xcodeproj/project.xcworkspace/xcuserdata/dcsnail.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/image/gesture.gif b/image/gesture.gif new file mode 100644 index 0000000..2175b41 Binary files /dev/null and b/image/gesture.gif differ