Touch coordinates in iPhone landscape mode app
- by gok
I am trying to make this landscape only iphone app.
I only use this code for this purpose:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
However when I click clip subviews checkbox from interface builder, the view is clipped from the middle.
I also don't receive any touch events from outside of view bounds obviously.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint fingerPos = [[touches anyObject] locationInView:self.view];
NSLog(@"%f %f",fingerPos.x,fingerPos.y); }
only prints for coordinates between 20 and 320 for X. But Y works fine.
When i try to modify bounds by hand, everything works fine; View is positioned and shown correctly, printed coordinates are correct, I receive touch from all of the screen except between 0 and 20 for X. So Left side of the screen is unresponsive to touch events for only 20 pixels. Code I use to modify bounds:
self.view.bounds = CGRectMake(-180.0f, 0.0f, 680.0f, 480.0f);
What might be causing this? Weird!