I've created programmatically a View, an UIImageView and a Button. The problem is that i need to update their position if the device switches from Portrait to Landscape, how can I do it?
This should be the code that checks if the Device is in Portrait or Landscape mode
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
}
else
{
}
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
//change the frame for sideways direction
btn.frame=CGRectMake(x,y,width,height);
imgView.frame=CGRectMake(x,y,width,height);
view.frame=CGRectMake(x,y,width,height);
}
else
{
//change the frame for up/down
btn.frame=CGRectMake(x,y,width,height);
imgView.frame=CGRectMake(x,y,width,height);
view.frame=CGRectMake(x,y,width,height);
}
}