NimbleKit - fast iOS app development

Shake Detection

Forum for posting sample code and examples, new posts creation is not allowed, but everybody can comment

Shake Detection

Postby sunny » Fri Aug 28, 2009 4:57 pm

This example shows how to implement shake detection.
And yes, it works only on real device
Attachments
shake.zip
Updated to work with NK 1.9.2+
(17.2 KiB) Downloaded 581 times
User avatar
sunny
Staff
 
Posts: 2707
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: Shake Detection

Postby tomtom » Wed Sep 02, 2009 4:59 pm

And it works also on my device
Thanks for your help :-)
tomtom
 
Posts: 6
Joined: Wed Sep 02, 2009 4:54 pm

Re: Shake Detection

Postby Andy Baird » Thu Sep 03, 2009 9:44 pm

"And yes, it works only on real device"

Just out of curiosity, did you try it with the Hardware > Shake Gesture command in the iPhone Simulator? I've never had the opportunity to use that Simulator feature, but it should work... :-)

Andy Baird
User avatar
Andy Baird
 
Posts: 113
Joined: Sat May 30, 2009 10:32 pm
Location: On the road in the southwestern US

Re: Shake Detection

Postby sunny » Thu Sep 03, 2009 9:48 pm

no, it does not, because shake feature available only on iPhone OS 3.0 and in this example we use accelerometer to detect shake, so it can be used on 2.x also.
User avatar
sunny
Staff
 
Posts: 2707
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: Shake Detection

Postby billymay » Fri Sep 04, 2009 3:21 am

Hey guys,

If this is the shake code:
Code: Select all
<script type="text/javascript">
function deviceShook()
{
   NKAlert("Info", "The device has been shook");
}
</script>


What is the protocol to call a javascript function? I need to call: "showQuotes".

Thanks,

Billy
billymay
 
Posts: 73
Joined: Mon Aug 24, 2009 9:23 pm

Re: Shake Detection

Postby sunny » Fri Sep 04, 2009 1:18 pm

check APP_NAMEDelegate.m file for all the code.
there you can change function name or page where this has to be called
User avatar
sunny
Staff
 
Posts: 2707
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: Shake Detection

Postby billymay » Fri Sep 04, 2009 2:27 pm

The javascript is in my html file and the function name is showQuotes. Can I not just add something like:

Code: Select all
<script type="text/javascript">
function deviceShook()
{
'showQuotes()';
}
</script>


... which doesn't work btw... any ideas?

Billy
billymay
 
Posts: 73
Joined: Mon Aug 24, 2009 9:23 pm

Re: Shake Detection

Postby sunny » Fri Sep 04, 2009 2:34 pm

if you have showQuotes() function in the same file this has to work (I tried)

Code: Select all
<script type="text/javascript">
function showQuotes()
{
   NKAlert("Info","showQuotes called");
}
function deviceShook()
{
    showQuotes();
}
</script>
User avatar
sunny
Staff
 
Posts: 2707
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: Shake Detection

Postby billymay » Fri Sep 04, 2009 3:44 pm

Thanks Sunny, that did work.

Billy
billymay
 
Posts: 73
Joined: Mon Aug 24, 2009 9:23 pm

Re: Shake Detection

Postby tarnfeld » Fri Sep 18, 2009 6:41 pm

Used this in Snippety Snip 1.2 update :) Now in the app store!
Check it out - all reviews are appreciated!
http://itunes.apple.com/WebObjects/MZSt ... 45111&mt=8

Also have two great apps in mind, one should be released - well submitted - in the next week or so and the other in a month maybe more / less :)
tarnfeld
 
Posts: 189
Joined: Mon Jun 15, 2009 9:37 pm

Next

Return to Sample Code

Who is online

Users browsing this forum: No registered users and 2 guests