开发者

Iphone sdk - moving a UIImageView with the Accelerometer?

开发者 https://www.devze.com 2022-12-10 09:24 出处:网络
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开发者_如何学

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消