Iphone sdk - moving a UIImageView with the Accelerometer?
I haven't had any experience with the accelerometer yet and i was wondering how i would move my UIImageView with the accelerometer, can anyone point me to any tutorials or give me a litt开发者_如何学JAVAle help? thanks, harry
There are a collection of tutorials here http://www.iphonedevforums.com/forum/sdk-coding-help/854-how-use-accelerometer.html which should meet your needs.
//viewDidLoad UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer]; accel.delegate = self; accel.updateInterval = 1.0f/60.0f; //then - (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler { //move your image here //based on aceler.x aceler.y aceler.z }
精彩评论