IOS: How to Change Landscape Orientation Xs and Ys
My app will only be terrain. I am having serious problems with variables of width, height, x and y. Is there a way to change all of the width, height, x and y values so I don't have to change all the coordinates in my application? (Ie (x, y) should become (y, x) and something. Width should be something.).
Here is a concrete example of my problems:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchPoint = [touch locationInView:unitArea];
if (CGRectContainsPoint(self.view.frame, touchPoint))
{
NSLog(@"released in area");
}
}
This does not work in terrain ... It is using the wrong coordinates and in some places it will output "released in area" but not in the actual area the view is in.
unitArea bounds are <UIView: 0x6a52420; frame = (20 0; 300 480); transform = [0, -1, 1, 0, 0, 0]; autoresize = RM+BM; layer = <CALayer: 0x6a524a0>>
This shows that my view is limited when it should be (0 20; 480 300).
Edit, in more detail:
Here is my orientation method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
And in the project summary, my "Oriented Supported Devices" is set to landscape only.
+3
source to share
1 answer