0
A
回答
0
@interface FirstViewController : UIViewController <UIAccelerometerDelegate> {
IBOutlet UIImageView *imageView;
CGPoint delta;
CGPoint translation;
float ballRadius;
}
//implementation
- (void)viewDidLoad
{
[super viewDidLoad];
// for the line in the middle of the camera
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1.0f/60.0f;
}
- (void)accelerometer:(UIAccelerometer *)acel
didAccelerate:(UIAcceleration *)acceleration {
// Get the current device angle
float xx = -[acceleration x];
float yy = [acceleration y];
float angle = atan2(yy, xx);
// Add 1.5 to the angle to keep the image constantly horizontal to the viewer.
[imageView setTransform:CGAffineTransformMakeRotation(angle+1.5)];
}
相关问题
- 1. 我怎样才能加速我的基于事件的过程?
- 2. 我怎样才能让我的Python代码的运行速度
- 3. 我怎样才能让我的silverlight控制加载速度更快
- 4. 我怎样才能重定向到基于URL中的Grails
- 5. 我怎样才能重定向基于选择一个DropDownList的
- 6. 我怎样才能使加速度计从iphone到后台工作?
- 7. 我怎样才能让我的启动板下载速度更快
- 8. 在tflearn我怎样才能添加偏见在基于mnist的模型开始
- 9. 我怎样才能在迅速
- 10. 我怎样才能让这个外部JMS客户端终止?
- 11. 怎样才能让android中
- 12. 我怎样才能得到我精灵的速度?
- 13. 我怎样才能让在装配
- 14. 我怎样才能让CSS动画
- 15. 我怎样才能让侧边栏
- 16. 我怎样才能让它干?
- 17. 我怎样才能让吐司消失?
- 18. 我怎样才能让课程“重设”?
- 19. 我怎样才能让深性质
- 20. 我怎样才能让猫壳循环?
- 21. 我怎样才能让-drawRect执行?
- 22. 我怎样才能让$ routeProvider在angularjs
- 23. 我怎样才能让这个更好
- 24. 我怎样才能让StackPanel使用ItemTemplate?
- 25. 我怎样才能让joomla3.x
- 26. 我怎样才能让我的包装100%的高度?
- 27. 我怎样才能让我的SQL计数函数返回0?
- 28. 我怎样才能
- 29. 我怎样才能让剧情从零开始?
- 30. 我怎样才能找到统计员的最终位置?
感谢张贴一个答案!虽然代码片段可以回答这个问题,但添加一些附加信息仍然很棒,比如解释等。 – j0k