iOS development-advanced technology & Shake-shake function implementation

Source: Internet
Author: User
<span id="Label3"></p><p style="text-align: center;"><p style="text-align: center;"><span style="font-size: 18pt;">The realization of shaking and shaking function</span></p></p><p style="text-align: center;"><p style="text-align: center;"></p></p><p><p>The variety of functions in the AppStore is being used more and more, so we start to introduce some of the more practical iOS development today, but we touch less features, we start with a shake function first</p></p><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style:none; margin:0px!important; padding:0px!important; border:0px!important; outline:0px!important; border-top-left-radius:0px!important; border-top-right-radius:0px!important; border-bottom-right-radius:0px!important; border-bottom-left-radius:0px!important; background-image:none!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; box-sizing:content-box!important; font-family:consolas, ' bitstream Vera sans Mono ', ' Courier new ', Courier, monospace!important; font-size:1em!important; min-height:inherit!important; color:black!important; "> There's a way to do this in Uiresponder </code></code><pre><pre> <span style="color: #008080;">1 </span>-(<span style="color: #0000ff;">void </span>) motionbegan: ( Uieventsubtype) Motion withevent: (uievent *) <span style="color: #0000ff;">event </span> <span style="color: #000000;"> __osx_available_starting (__mac_na,__iphone_3_0); </span> <span style="color: #008080;">2 </span> <span style="color: #008080;">3 </span>-(<span style="color: #0000ff;"> void </span>) motionended: (uieventsubtype) motion withevent: (uievent *) <span style="color: #0000ff;">event </span> Span style= "color: #000000;" > __osx_available_starting (__mac_na,__iphone_3_0); <span style="color: #008080;">4 </span>-(<span style="color: #0000ff;">void </span>) motioncancelled: ( Uieventsubtype) Motion withevent: (uievent *) <span style="color: #0000ff;">event </span> __osx_available_starting (__ mac_na,__iphone_3_0); </pre></pre><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style:none; margin:0px!important; padding:0px!important; border:0px!important; outline:0px!important; border-top-left-radius:0px!important; border-top-right-radius:0px!important; border-bottom-right-radius:0px!important; border-bottom-left-radius:0px!important; background-image:none!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; box-sizing:content-box!important; font-family:consolas, ' bitstream Vera sans Mono ', ' Courier new ', Courier, monospace!important; font-size:1em!important; min-height:inherit!important; color:black!important; "></code></code> <code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style:none; margin:0px!important; padding:0px!important; border:0px!important; outline:0px!important; border-top-left-radius:0px!important; border-top-right-radius:0px!important; border-bottom-right-radius:0px!important; border-bottom-left-radius:0px!important; background-image:none!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; box-sizing:content-box!important; font-family:consolas, ' bitstream Vera sans Mono ', ' Courier new ', Courier, monospace!important; font-size:1em!important; min-height:inherit!important; color:black!important; "> > This is the way to do a shake. So how do you use these methods? </code></code><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style:none; margin:0px!important; padding:0px!important; border:0px!important; outline:0px!important; border-top-left-radius:0px!important; border-top-right-radius:0px!important; border-bottom-right-radius:0px!important; border-bottom-left-radius:0px!important; background-image:none!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; box-sizing:content-box!important; font-family:consolas, ' bitstream Vera sans Mono ', ' Courier new ', Courier, monospace!important; font-size:1em!important; min-height:inherit!important; color:black!important; "> > Very simple, you just have to let the controller itself support shaking </code></code><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style:none; margin:0px!important; padding:0px!important; border:0px!important; outline:0px!important; border-top-left-radius:0px!important; border-top-right-radius:0px!important; border-bottom-right-radius:0px!important; border-bottom-left-radius:0px!important; background-image:none!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; box-sizing:content-box!important; font-family:consolas, ' bitstream Vera sans Mono ', ' Courier new ', Courier, monospace!important; font-size:1em!important; min-height:inherit!important; color:black!important; "> and let him be the first corresponding person: </code></code> <code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"></code></code></code><pre><span style="color: #008080;"><span style="color: #008080;">1</span></span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) Viewdidload</span></span><span style="color: #008080;"><span style="color: #008080;">2</span></span> <span style="color: #008080;"><span style="color: #008080;">3</span></span> <span style="color: #008080;"><span style="color: #008080;">4</span></span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;">5</span></span> <span style="color: #008080;"><span style="color: #008080;">6</span></span> <span style="color: #008080;"><span style="color: #008080;">7</span></span> <span style="color: #000000;"><span style="color: #000000;">[superviewdidload];</span></span><span style="color: #008080;"><span style="color: #008080;">8</span></span> <span style="color: #008080;"><span style="color: #008080;">9</span></span> <span style="color: #008080;"><span style="color: #008080;">Ten</span></span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;">Do any <span style="color: #008000;">additional setup after loading the view, typically from a</span></span><span style="color: #008080;"><span style="color: #008080;"></span> one</span> <span style="color: #000000;"><span style="color: #000000;">nib.</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">[[uiapplicationsharedapplication]</span></span><span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #000000;"><span style="color: #000000;">setapplicationsupportsshaketoedit:yes];</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">[</span> self</span><span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #000000;"><span style="color: #000000;">becomefirstresponder];</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #008080;"><span style="color: #008080;"></span> at</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span>}</pre><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"><code style="list-style: none; margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace !important; font-size: 1em !important; min-height: inherit !important; color: black !important;"></code></code></code><p><p></p></p><span style="color: black; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace; font-size: 1em; line-height: 1.1em;"><span style="color: black; font-family: Consolas, ‘Bitstream Vera sans Mono‘, ‘Courier new‘, Courier, monospace; font-size: 1em; line-height: 1.1em;">and then we can get to the next few ways.</span></span><pre><span style="color: #008080;"><span style="color: #008080;">1</span></span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) motionbegan: (uieventsubtype) Motion</span></span><span style="color: #008080;"><span style="color: #008080;">2</span></span> <span style="color: #000000;"><span style="color: #000000;">withevent: (uievent</span></span><span style="color: #008080;"><span style="color: #008080;">3</span></span> <span style="color: #008080;"><span style="color: #008080;">4</span></span> <span style="color: #008080;"><span style="color: #008080;">5</span></span>*)<span style="color: #0000ff;"><span style="color: #0000ff;">Event</span></span><span style="color: #008080;"><span style="color: #008080;">6</span></span> <span style="color: #008080;"><span style="color: #008080;">7</span></span> <span style="color: #008080;"><span style="color: #008080;">8</span></span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;">9</span></span> <span style="color: #008080;"><span style="color: #008080;">Ten</span></span> <span style="color: #008080;"><span style="color: #008080;"></span> one</span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Shake detected</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">}</span></span><span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) motioncancelled: (uieventsubtype) motion withevent: (uievent</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span>*)<span style="color: #0000ff;"><span style="color: #0000ff;">Event</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #008080;"><span style="color: #008080;"></span> at</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Shake Cancel</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">}</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> in</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> to</span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) motionended: (uieventsubtype) motion withevent: (uievent</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span>*)<span style="color: #0000ff;"><span style="color: #0000ff;">Event</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #008080;"><span style="color: #008080;"></span> *</span> <span style="color: #008080;"><span style="color: #008080;"></span> $</span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;">Panax Notoginseng</span></span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Shaking End</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span> <span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span>(<span style="color: #0000ff;"><span style="color: #0000ff;">Event</span></span>. Subtype = =<span style="color: #000000;"><span style="color: #000000;">Uieventsubtypemotionshake) {</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> $</span> <span style="color: #008080;"><span style="color: #008080;"></span> $</span> <span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">something</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">happens</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;">Wuyi</span></span> <span style="color: #000000;"><span style="color: #000000;"> }</span></span><span style="color: #008080;"><span style="color: #008080;"></span> the</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> wu</span>}</pre><p><p></p></p><span style="font-size: 14pt;"><span style="font-size: 14pt;">Let's start by simply using It:</span></span>We just need to implement the following code in the controller to achieve the shaking function<pre><span style="color: #008080;"><span style="color: #008080;">1</span></span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) viewdidappear: (BOOL) animated</span></span><span style="color: #008080;"><span style="color: #008080;">2</span></span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;">3</span></span> <span style="color: #000000;"><span style="color: #000000;">[super viewdidappear:animated];</span></span><span style="color: #008080;"><span style="color: #008080;">4</span></span> <span style="color: #000000;"><span style="color: #000000;">[self becomefirstresponder];</span></span><span style="color: #008080;"><span style="color: #008080;">5</span></span> <span style="color: #000000;"><span style="color: #000000;">}</span></span><span style="color: #008080;"><span style="color: #008080;">6</span></span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">) viewwillappear: (BOOL) animated</span></span><span style="color: #008080;"><span style="color: #008080;">7</span></span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;">8</span></span> <span style="color: #000000;"><span style="color: #000000;">[self resignfirstresponder];</span></span><span style="color: #008080;"><span style="color: #008080;">9</span></span> <span style="color: #000000;"><span style="color: #000000;">[super viewwillappear:animated]; </span></span><span style="color: #008080;"><span style="color: #008080;">Ten</span></span> <span style="color: #000000;"><span style="color: #000000;">}</span></span><span style="color: #008080;"><span style="color: #008080;"></span> one</span>-<span style="color: #000000;"><span style="color: #000000;">(BOOL) Canbecomefirstresponder</span></span><span style="color: #008080;"><span style="color: #008080;"></span> a</span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #0000ff;"><span style="color: #0000ff;">return</span></span><span style="color: #000000;"><span style="color: #000000;">YES;</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">}</span></span><span style="color: #008080;"><span style="color: #008080;"></span> the</span>- (<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span>) motionbegan: (uieventsubtype) Motion withevent: (uievent *)<span style="color: #0000ff;"><span style="color: #0000ff;">Event</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;">{</span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span>(motion = =<span style="color: #000000;"><span style="color: #000000;">Uieventsubtypemotionshake) {</span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span>NSLog (<span style="color: #800000;"><span style="color: #800000;">@"</span></span><span style="color: #800000;"><span style="color: #800000;">Shake a</span> shake</span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">); </span></span><span style="color: #008080;"><span style="color: #008080;"></span> -</span> <span style="color: #000000;"><span style="color: #000000;"> } </span></span><span style="color: #008080;"><span style="color: #008080;"></span> +</span>}</pre><p><p></p></p><p><p>It is also worth mentioning that the "shake" function can be tested by "hardware"-"shake gesture" when running in the Simulator.</p></p><p><p></p></p><p><p>iOS development-advanced technology & Shake-shake function implementation</p></p></span>

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.