Jitter at 3.0 in UITableViewController

after reading some posts about implementing shaking on 3.0, I think I am getting this idea, but I am not getting any call:

motionBegan motionEnded motionCancelled

this is an example of what i read: how to detect and program around shaking for iphone

I'm sure added

[self becomeFirstResponder]; 

and

 -(BOOL)canBecomeFirstResponder { NSLog(@"First responder"); return YES; } 

Should I include a special delegate for these events?

I understand that these events are controlled by the system and they are transmitted to the first responder and continue ...

any idea?

thanks,

g.

0
source share
2 answers

I had a lot of problems for this to work, and I finally gave up and followed the advice of jandrea. He proposed to subclass UIWindow and implement the movement indicated there. This is a quote from his post here , look for him quite far.

First, I subclassed UIWindow. It is very simple. Create a new class file with an interface such as MotionWindow: UIWindow (feel free to choose your own, natch). Add a method like this:

 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake) { [[NSNotificationCenter defaultCenter] postNotificationName:@"DeviceShaken" object:self]; } } 

Change @ "DeviceShaken" to the notification name of your choice. Save file.

Now, if you use MainWindow.xib (material for the Xcode template), go in there and change the class of your Window Object from UIWindow to MotionWindow or whatever you call It. Save xib. If you configured UIWindow programmatically, use the new Window class instead.

Your application now uses the specialized UIWindow Class. Wherever you want to talk about shaking, register to notify them! Like this:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceShaken) name:@"DeviceShaken" object:nil]; 

To remove yourself as an observer:

 [[NSNotificationCenter defaultCenter] removeObserver:self]; 
+1
source

Where do you call becomeFirstResponder ? You must do this in viewDidAppear . Does it quit?

0
source

All Articles