Hello Everyone我正在实现基于加速度计的摆动画。 但它给出了奇怪的行为。下面是我的代码。 请帮我找到我错的地方。
#import "DemoViewController.h"
@interface DemoViewController ()
@end
@implementation DemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIAccelerometer* theAccel=[UIAccelerometer sharedAccelerometer];
theAccel.updateInterval=1/50.0f;
theAccel.delegate=self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
CGFloat x= acceleration.x;
self.imPendulum.transform=CGAffineTransformRotate(self.imPendulum.transform,-x);
}
@end