Hi,
I am rotating a wheel which various subviews (UIImageViews and UIButtons) However when I ask it to display each and every centre of every subview, it is giving me the same value everytime.
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
int len = [allTouches count]-1;
UITouch *touch =[[allTouches allObjects] objectAtIndex:len];
CGPoint location = [touch locationInView:[self superview]];
float theAngle = atan2( location.y-self.center.y, location.x-self.center.x );
totalRadians = theAngle;
[self rotateImage:theAngle];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}
-(void) rotateImage:(float)angleRadians{
self.transform = CGAffineTransformMakeRotation(angleRadians);
CATransform3D rotatedTransform = self.layer.transform;
self.layer.transform = rotatedTransform;
int count = 0;
for (UIView *subview in self.subviews)
{
count++;
//these values are always the same
NSLog(@"%i %f %f", count, subview.center.x, subview.center.y);
}
}
May someone please tell me why the values are always coming the same even after being rotated and placed in a different position?
Thanks!