I got several images within my view. When i rotate my device I'd like to have my images being translated with the CGAffineTransformTranslate method so that the images are placed properly within my Landscape View. After I rotate back to Portrait the opposit translation needs to take place.
The translation works so far. However the translation is also being done when I touch and drag the image. How can I make sure that the translation only works on rotation and not with touch and drag.
Here's a part of my code so far:
Hope someone got an answer this is bothering me all day long. Thanks in advance
The translation works so far. However the translation is also being done when I touch and drag the image. How can I make sure that the translation only works on rotation and not with touch and drag.
Here's a part of my code so far:
Code:
-(void) touchesMoved: (NSSet *)touches withEvent: (UIEvent *) event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if ([touch view] == image1) {
image.center = location;
}
[super viewDidLoad];
}
-(void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation {
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait ||
fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
image1.transform = CGAffineTransformTranslate(image1.transform, -64, 145);
}
if(fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
image1.transform = CGAffineTransformTranslate(image1.transform, 64, -145);
}
Last edited by a moderator: