Reputation: 45
I am brand new to iOS development, and I am trying to implement a rotatable and resizable user interface. The problem that I am encountering is re-setting the position of UI elements upon rotation. I can't even get the simple code below to work properly:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL)shouldAutorotate {
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
self.button.frame = CGRectMake(502.0, 207.0, 73.0, 44.0);
} else {
self.button.frame = CGRectMake(197.0, 69.0, 73.0, 44.0);
}
}
I have de-selected the Autoresize Subviews option; however, the button still ends up in the same spot. I have logged the frame position, which appears to have the correct coordinates, but it is definitely not ending up that way.
Upvotes: 2
Views: 252
Reputation: 1199
in the first panel of Utility inspect. uncheck the use auto-layout.
Upvotes: 1