Skip to content

Commit

Permalink
Add GestureRecognizer
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyanchang committed Feb 26, 2019
1 parent 07d589f commit 7984acf
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
56 changes: 56 additions & 0 deletions Watch-App-Sampler WatchKit App/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1034,5 +1034,61 @@
</objects>
<point key="canvasLocation" x="-953" y="-187"/>
</scene>
<!--GestureRecognizerController-->
<scene sceneID="IVu-90-og4">
<objects>
<controller identifier="GestureRecognizerController" id="t9P-Ef-1eh" customClass="GestureRecognizerController" customModule="Watch_App_Sampler_WatchKit_Extension">
<items>
<label width="1" height="71" alignment="left" text="Tap Me" textAlignment="center" numberOfLines="0" id="doN-Rg-hjK">
<gestureRecognizers>
<tapGestureRecognizer id="m8c-QM-djH">
<connections>
<action selector="tapAction:" destination="t9P-Ef-1eh" id="Zvd-WK-waK"/>
</connections>
</tapGestureRecognizer>
</gestureRecognizers>
<fontDescription key="font" type="system" pointSize="16"/>
</label>
<label width="1" height="64" alignment="left" text="LongPress Me" textAlignment="center" numberOfLines="0" id="cB8-Wy-7Ky">
<gestureRecognizers>
<longPressGestureRecognizer id="lsQ-h1-Oec">
<connections>
<action selector="longPressAction:" destination="t9P-Ef-1eh" id="KiL-TT-Atb"/>
</connections>
</longPressGestureRecognizer>
</gestureRecognizers>
<fontDescription key="font" type="system" pointSize="16"/>
</label>
<label width="1" height="75" alignment="left" text="Swipe Me" textAlignment="center" numberOfLines="0" id="qAd-mf-2l7">
<gestureRecognizers>
<swipeGestureRecognizer id="ArF-zL-1JY">
<connections>
<action selector="swipeAction:" destination="t9P-Ef-1eh" id="S5e-cB-Q2F"/>
</connections>
</swipeGestureRecognizer>
</gestureRecognizers>
<fontDescription key="font" type="system" pointSize="16"/>
</label>
<label width="1" height="75" alignment="left" text="Pan Me" textAlignment="center" numberOfLines="0" id="WNK-3w-vIK">
<gestureRecognizers>
<panGestureRecognizer id="NNz-bU-N2C">
<connections>
<action selector="panAction:" destination="t9P-Ef-1eh" id="tTI-XU-zrb"/>
</connections>
</panGestureRecognizer>
</gestureRecognizers>
<fontDescription key="font" type="system" pointSize="16"/>
</label>
</items>
<connections>
<outlet property="longPressLabel" destination="cB8-Wy-7Ky" id="R98-Ci-3N1"/>
<outlet property="panLabel" destination="WNK-3w-vIK" id="duQ-Q9-iFw"/>
<outlet property="swipeLabel" destination="qAd-mf-2l7" id="GYS-Ea-apw"/>
<outlet property="tapLabel" destination="doN-Rg-hjK" id="YIN-52-kqB"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="-297" y="252"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -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!")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
4 changes: 4 additions & 0 deletions Watch-App-Sampler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -131,6 +132,7 @@
5F2AA6B620D3C31500D0DE5D /* RecordController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordController.swift; sourceTree = "<group>"; };
5F3FB9112200427000F30007 /* loading.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = loading.gif; sourceTree = "<group>"; };
5F55F883221D655900323342 /* AudioFilePlayerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioFilePlayerController.swift; sourceTree = "<group>"; };
5F55F885221D810B00323342 /* GestureRecognizerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GestureRecognizerController.swift; sourceTree = "<group>"; };
5F680FBC20F714B2001E0434 /* Watch-App-Sampler WatchKit Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Watch-App-Sampler WatchKit Extension.entitlements"; sourceTree = "<group>"; };
5F6C763620E4CFDD006DEA42 /* AlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertController.swift; sourceTree = "<group>"; };
5F76440020D91669003AB207 /* MessageController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -259,6 +261,7 @@
isa = PBXGroup;
children = (
5F76440A20DA62A7003AB207 /* MenusController.swift */,
5F55F885221D810B00323342 /* GestureRecognizerController.swift */,
5F6C763620E4CFDD006DEA42 /* AlertController.swift */,
5FD7890820DBB4E100381EFE /* PickerController.swift */,
5F2AA6B020D3BFCA00D0DE5D /* ProgressController.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down
Binary file not shown.
Binary file added image/gesture.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7984acf

Please sign in to comment.