Shake Detection

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

Re: Shake Detection

Postby tgatzoulis » Wed Jun 30, 2010 12:16 am

Dear Sunny,
is there any chance you can make this example to work with NK 1.9 (iOS 4)?

Thanks in advance
tgatzoulis
 
Posts: 13
Joined: Sun May 23, 2010 12:17 am

Re: Shake Detection

Postby norwegian » Fri Jul 23, 2010 3:00 am

tgatzoulis: It does work with NK 1.9
You have most likely just missed out on some code in shakeAppDelegate.h and/or shakeAppDelegate.m
norwegian
 
Posts: 70
Joined: Sat Oct 17, 2009 6:58 pm

Re: Shake Detection

Postby apt » Wed Jul 28, 2010 3:52 pm

I've successfully implemented the deviceshook function but have come across a problem.

I have my app trigger an NKAlertSheet when it detects a shake but while the alert sheet is visible I can freely shake the device again and produce multiple alert sheets on top of each other which all need to be dismissed before continuing.

My question is how do I disable the device shook function once its been activated?

Thanks in advance.

Adrian
Adrian Thompson
Founder
http://www.taptapp.co.uk

NimbleKit Registered User: U853078901
User avatar
apt
NimbleKit Expert
 
Posts: 322
Joined: Fri Jan 29, 2010 11:52 pm
Location: Sheffield, UK

Re: Shake Detection

Postby sluggish » Wed Jul 28, 2010 4:50 pm

i think that it is possible with NKSettings...

i use this code to check the counts of the three first times when the App is launched, you can modify it for check the count of the shakes, something like this:

Code: Select all
function checkRunCount(){ 
   var settings = new NKSettings();
   Count = settings.getValueForKey("runCount");
   if (Count == "(null)")   
   Count = 0;
   settings.setValueForKey(Count + 1, "runCount");
   Cuenta = 2 - Count
   if(Count < 3 ){
      showSheet();
   }
}
function showSheet(){
// js code of NKAlertSheet

}
sluggish
NimbleKit Expert
 
Posts: 74
Joined: Fri Jan 08, 2010 4:18 am
Location: Madrid / Spain

Re: Shake Detection - 1.9

Postby jezjones » Sat Aug 07, 2010 4:26 pm

Hi,

I am having trouble implementing this in 1.9 in the ..appDelegate.m file.

In my applicationDidFinishLaunching method, i have copied everything from the example into my project but I am getting an error on the line starting with while the mainWebViewLoaded is false, this line is not in the example;-

Code: Select all
- (void)applicationDidFinishLaunching:(UIApplication *)application {   

   Nimble *nimble = [[Nimble alloc] initWithRootPage:@"main.html" window:window serial:@"xxxxx"];
   [window addSubview:nimble.view];
   [window makeKeyAndVisible];
   [nimble release];
   [UIAccelerometer sharedAccelerometer].delegate = self; // [sunny] don't forget this!
   while (!_mainWebViewLoaded) {  // here is where i get the error
      [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
   }   
}



And the error is ;-

class '..appDelegate' does not implement the 'UIAccelerometerDelegate' protocol


Can anyone give me any hints on where i need to define this?

THanks.
jezjones
 
Posts: 36
Joined: Thu Mar 11, 2010 3:12 pm

Re: Shake Detection

Postby sunny » Sat Aug 07, 2010 5:28 pm

then also check the .h file for delegate class, there has to be <UIAccelerometerDelegate> after superclass name, which you need to add too.
P.S.
is "does not implement protocol" error? Usually it is just warning, which can be ignored
User avatar
sunny
Staff
 
Posts: 1786
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Re: Shake Detection

Postby jezjones » Sat Aug 07, 2010 5:42 pm

Thanks for the quick response!

Yes it does run, but then crashes on load with an exception;-

-[Nimble view]: unrecognized selector sent to instance 0x8119670
2010-08-07 16:40:14.921 Dr Goodlovins Love Test[2635:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Nimble view]: unrecognized selector sent to instance 0x8119670'

Also which .h do you mean? I have only the ..appDelegate.h file and then the nimble.h and NKBridge.h , this is the only bit of obj-c in a nimblekit project.
jezjones
 
Posts: 36
Joined: Thu Mar 11, 2010 3:12 pm

Re: Shake Detection

Postby sunny » Sat Aug 07, 2010 5:52 pm

remove the line
Code: Select all
[window addSubview:nimble.view];

this sample code was made with very old NimbleKit, once you removed it then it has to work.
I will re-upoad new sample code updated
User avatar
sunny
Staff
 
Posts: 1786
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Re: Shake Detection

Postby sunny » Sat Aug 07, 2010 5:57 pm

sample code updated
User avatar
sunny
Staff
 
Posts: 1786
Joined: Sat May 30, 2009 5:18 am
Location: kiev, Ukraine

Re: Shake Detection

Postby jezjones » Sat Aug 07, 2010 5:59 pm

Thanks again for a really quick reply!

That has made it compile ok in my project (with the does not implement protocol warning ) so now i will try it out with a device etc.

Thanks again!! :D
jezjones
 
Posts: 36
Joined: Thu Mar 11, 2010 3:12 pm

Previous

Return to Sample Code

Who is online

Users browsing this forum: No registered users and 1 guest