views:

34

answers:

1

Hello all.

I have 3 subviews in a UITabBarController. The first tab's view has objects which are manually moved when willAnimateRotationToInterfaceOrientation is called. However, if another tab's view is visible on rotate, willAnimateRotationToInterfaceOrientation is never called, and the items on the first tab's view are not in the right place if I go back to the first tab.

How can i manually move objects in one view on rotate when another view is visible?

A: 

I solved it. What I did was create a method, called from ViewWillAppear, that gets the current orientation and makes changed to objects positions on screen.

Hope this helps someone.

- (void)manuallyMoveViewObjects{

UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
    CGRect buttonFrame = CGRectMake(125.0, 223.0, 70.0, 50.0);

    self.button.frame = buttonFrame;
}

else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
    CGRect gbuttonFrame = CGRectMake(205.0, 131.0, 70.0, 50.0);
    self.button.frame = buttonFrame;

}

}

DysonApps
Vote up for working out your own solution.
Jordan
It won't let me. Says I can't do that.
DysonApps