0
私はいくつかのhelp.How UIImageViewを画面でタップすると回転する必要がありますか?TapGestureでUIImageViewを回転
- (void)viewDidLoad {
UITapGestureRecognizer *tapgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[self.view addGestureRecognizer:tapgr];
[tapgr release];
[super viewDidLoad];
}
-(void)tap:(UITapGestureRecognizer *)gesture {
CGPoint touch = [gesture locationInView:self.view];
CGPoint center = myImage.center;
float dx,dy,wtf;
dx = touch.x-center.x;
dy = touch.y-center.y;
wtf = atan2f(dy, dx);
[self rotateImage:self.myImage withAngle:wtf];
}
- (void)rotateImage:(UIImageView *)image withAngle:(float)newAngle
{
image.transform = CGAffineTransformMakeRotation(newAngle);
}
- 間違いはどこですか?