0
我還沒有加速度計的任何經驗,我想知道如何將我的UIImageView與加速度計移動,任何人都可以指向我的任何教程或給我一點幫助? 謝謝, 哈里iphone sdk - 用加速度計移動UIImageView?
我還沒有加速度計的任何經驗,我想知道如何將我的UIImageView與加速度計移動,任何人都可以指向我的任何教程或給我一點幫助? 謝謝, 哈里iphone sdk - 用加速度計移動UIImageView?
這裏有一個教程集合http://www.iphonedevforums.com/forum/sdk-coding-help/854-how-use-accelerometer.html它應該滿足您的需求。
//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 }