Accelerometer didAccelerate delegate method not getting called in iOS sdk 6.0 - ios

I am developing application to get threshold how forcefully user shook iOS device. I am using iOS sdk 6.0.
I tried UIResponder delegate method motionEnded:: It get called when device is shaken but do not give enough data that how forcefully some one shook device.
I searched enough and found a single solution to use UIAccelerometer didAccelerate call back method. But it is not getting called. Is it sdk issue? As this method is deprecated in iOS 5.
I also tried coreMotion framework but that gives gyroscope data that how much device have been rotated but not how much it is has been shaken.
What is the best way of doing this.
I followed How do I detect when someone shakes an iPhone? but found no useful answer.

I just figured it out. iOS simulator do not respond to UIAccelerometer actions even if you perform shake gesture or rotate the simulator. It will not work. But if you run on device you will find same piece of code is running fine :)

Try this, in your view did load just do this:
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
This made it work for me. Dont need to use the variable at all, but it has something to do with setting the shared accelerometers delegate to self

Related

Using UIDeviceOrientation change notification instead of viewillTransistionToSize

I have managed to support Portrait and Landscape orientations for my app.
However, my implementation is based on UIDeviceOrientationChangeNotification. I do not use viewillTransistionToSize
Offical Apple sample code for AlternateViews does use notification based approach. So I assumed it should be fine.
Is there any significant advantage/disadvantage of using one over another?
Would it ever happen that my app will not get deviceOrientationChangenotification?
Please clarify.
I am using a combination of both. But to me it looks like viewillTransistionToSize gives more control as you can execute code
before rotation begins
during rotation
after rotation
while in case of Notification you only execute code after rotation.
Not sure but I found this thru experimentation and not thru docs.

IOS Rotation Notification does not work

I'm trying NSNotificationCenter with this code:
but does not print anything, never enters in the rotate function, any ideas? thanks a lot
Did you confirm that you've enabled the appropriate orientations under App General settings?

Detect if iPhone has moved

I'm trying to detect if an iPhone was moved (even a slight movement), and then if the device was moved, i want the iPhone to play a sound.
Im new to IOS programming, and I've looked through a bunch of apple documentations, and i found that i must use CoreMotion . But I'm not sure how to implement it, to what id like to do in my app.
I've also searched on google for some help (e.g. NSHipster...), but i couldn't fine anything that meets my needs.
can anyone assist?
Thank you.
It seems that you need the motion accelerometer in CMMotionManager.
https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionManager_Class/index.html#//apple_ref/occ/instm/CMMotionManager/accelerometerData
It seems you want to detect an iPhone shake. Apple has an article on the subject:
https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html#//apple_ref/doc/uid/TP40009541-CH6-SW2

Does the AdInsterstitialAd no longer work with iOS 7?

I have an iPad application where I have integrated the AdInsterstitialAd but it looks like the delegate method:
-(void)interstitialAdDidUnload
is no longer called when closing the ad in iOS 7. I wanted to know if anyone else has experienced this issue or has found away around this? The unload method is important for me because that is when I want to resume my app's timers (the app pauses itself while the ad is displayed).
I have looked on Apple's website and haven't found anything useful and their current InterstitialAd sample has the same issue.

What is the name of the method for screenshot on iOS

I was wondering if there was a specific method called when we press the 2 buttons of the iPhone (using Home-Button & Power on/off) to take a screenshot. If yes, I would known his name to use her in programming.
There used to be a UIGetScreenImage() function that you could use to capture the screen. Apple no longer allows use of that function in App Store apps, so you have a few other options. CALayer has a -renderInContext: method—Google it—that you can use to copy a view’s contents to a graphics context; this does not, however, work for OpenGL content, video, or live imagery from a device’s camera. I’m not sure about solutions for the first two, but for the latter—getting images from the camera—you’ll need to use the AVFoundation framework.
It is a system level service for which the app never receives any notification or method call.
I believe that would be a native method, not accessible from the IPhone SDK. In what context are you going to be using this? You might be looking for this - Take screenshot from code

Resources