I am trying to get the accelerometer to detect shakes in a separate view and the accelerometer method does not get called?
When I place code to set the accelerometer attributes in the controllers viewDidLoad method and add the ......didAccelerate:(UIAcceleration *) acceleration in the implementation file for the controller shakes are detected.
I'm a novice to iphone development and think that perhaps the code:
accelerometer.delegate = self;
should point to the view? Rather than self?
Any help would be really appreciated. I'm really not sure how to solve this?
If your accelerometer callback method is not being called there's a good chance your application delegate (or other custom class) is not supporting the UIAccelerometerDelegate
class. Some very loose pseudocode on making that delcaration in your application delegate...
@interface MyApplicationDelegate: UIApplicationDelegate<UIAccelerometerDelegate>
{
.. class definition stuff ..
}
See the Apple documentation here...
And review the Accessing Accelerometer Events section