Questions tagged [uiaccelerometer]

The UIAccelerometer class lets you register to receive acceleration-related data from the onboard hardware. As a device moves, its hardware reports linear acceleration changes along the primary axes in three-dimensional space. You can use this data to detect both the current orientation of the device (relative to the ground) and any instantaneous changes to that orientation. Deprecated in iOS 5.0. Available in iOS 2.0 and later.

Deprecated in iOS 5.0. Available in iOS 2.0 and later. The UIAccelerometer class lets you register to receive acceleration-related data from the onboard hardware. As a device moves, its hardware reports linear acceleration changes along the primary axes in three-dimensional space. You can use this data to detect both the current orientation of the device (relative to the ground) and any instantaneous changes to that orientation. You might use instantaneous changes as input to a game or to initiate some action in your application.

You do not create accelerometer objects directly. Instead, you use the shared UIAccelerometer object to specify the interval at which you want to receive events and then set its delegate property. Upon assigning your delegate object, the accelerometer object begins delivering acceleration events to your delegate immediately at the specified interval. Events are always delivered on the main thread of your application.

The maximum frequency for accelerometer updates is based on the available hardware. You can request updates less frequently but cannot request them more frequently than the hardware maximum. Once you assign your delegate, however, updates are delivered regularly at the frequency you requested, whether or not the acceleration data actually changed. Your delegate is responsible for filtering out any unwanted updates and for ensuring that the amount of change is significant enough to warrant taking action.

For more information about the data delivered to your observer, see UIAcceleration Class Reference. For information about implementing your delegate object, see UIAccelerometerDelegate Protocol Reference.

113 questions
2
votes
3 answers

Using the Android Accelerometer without having the device flat

I've been playing around with the Android Accelerometer of late using the Android SDK and the Adobe AIR for Android SDK on my Motorola Droid. What I've noticed is that the accelerometer works just fine, but I was wondering if it is possible to…
Shawn
  • 2,406
  • 1
  • 26
  • 31
2
votes
1 answer

UIAccelerometer and UIScrollView

I want to scroll a scrollview based on the UIAccelerometer values. What is the best way to accomplish this? Initially I set the content offset to a value based on the accelerometer values I get. Then on each scrollViewDidEndAnimating, I again set…
Mahadevan
  • 23
  • 2
2
votes
0 answers

Using iphone accelerometer AND UIEventSubtypeMotionShake event simultaneousluy

I am using accelerometer to move/change things on the screen in my app. I also need to detect UIEventSubtypeMotionShake in the view controller for some other animations. As my app is a simple view based app, there is just one view controller which…
Swapnil Luktuke
  • 10,385
  • 2
  • 35
  • 58
2
votes
1 answer

Is there any working algorithm to count steps on all iOS devices (with or without M7 chip)?

I want to make an app. that count user steps. So for that I have searched through the google but didn't found anything that could really help me. Although I came to know that by using Accelerometer data we can get the steps and I tried with this…
Narender Tak
  • 241
  • 2
  • 12
2
votes
1 answer

ios accelerometer values at any orientation

Accelerometer values are provided with respect to the device orientation.. My goal is to get these values irrespective of the device position. In a considered scenario, if the device is placed in a vehicle, placed face up or horizontally, the…
nr5
  • 4,228
  • 8
  • 42
  • 82
2
votes
0 answers

How to convert accelerometer data into meter/second^2?

I want to Convert accelerometer reading in x,y,z axis into acceleration in meter/second^2.I am developing a windows phone application to calculate the distance traveled by a taxi.I have already gone through some of links like My Algorithm to…
2
votes
1 answer

How to implement pendulum animation based on accelerometer in ios

Hello Everyone i am implementing accelerometer based pendulum animation. But it gives strange behaviour . below is my code. Please help me to find where i am wrong. #import "DemoViewController.h" @interface DemoViewController…
Paresh Dudhat
  • 1,166
  • 1
  • 14
  • 28
2
votes
3 answers

How to calculate the G-Force value of a moving car using iPhone accelerometer values

I am working on app which is used to display the current G-Force value of a moving car on iPhone. I don't know how to calculate the G-force value using the iPhone accelerometer values. Also, I have to calculate distance and speed using these values.…
Vamshi
  • 21
  • 1
  • 3
2
votes
1 answer

Accelerometer Tilt Issue

So this is my first practice game I'm developing and first time using accelerometer so apologizes in advance if the answer is obvious. Would also like answered with code and explanation. So part of game I have a ball being rolled around no the…
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
2
votes
1 answer

programmatically detect if the iPhone fell on the ground

How to detect the iPhone fell on the ground using the UIAccelerometer? I am using the following delegate to calculate the falling detection but it's not working correctly. Is this calculation correct or not? Please suggest any other type of…
Mani
  • 1,310
  • 1
  • 20
  • 40
2
votes
1 answer

Using Accelerometer Simulator in XCode

Has anyone out there successfully used Accelerometer Simulator in their iPhone app? I am trying to use it in a COCOS2D app and cannot get it to work. The app and code and their usage are discussed here:…
Marc
  • 3,386
  • 8
  • 44
  • 68
2
votes
2 answers

UIImageView rotation affecting position?

I have a UIImageView that is set to move up and down the screen with the value of the accelerometer, using the following code: ship.center = CGPointMake(ship.center.x, ship.center.y+shipPosition.y); Where shipPosition is a CGPoint set in the…
Conor Taylor
  • 2,998
  • 7
  • 37
  • 69
2
votes
2 answers

accelerometer range in iPhone

i have implemented following method in my application. - (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler { if (fabsf(aceler.x) > 1.5 || fabsf(aceler.y) > 1.5 || fabsf(aceler.z) > 1.5 || fabsf(aceler.x) < -1.5 ||…
sagarkothari
  • 24,520
  • 50
  • 165
  • 235
2
votes
1 answer

UIAccelerometer more sensitive after calibration?

So I have done a basic calibration in my game like so: Calibrate Code: - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { [[NSUserDefaults standardUserDefaults] setFloat:acceleration.x…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
2
votes
1 answer

Calibrate UIAccelerometer?

In my app I use the accelerometer to control the character in my game. Right now I only allow the portrait orientation so the user has to tilt the device to the right or left in order to move the character. That is working fine so far. What I am…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191