In my iPhone app, I have a view controller with two views (essentially, a front & back view). The front view is the main UIView, and the back view is a secondary UIView which is added as a subview using [self.view addSubview:backView]
when showing the back and [backView removeFromSuperview]
when hiding it. However, when the orientation changes, I have the following issue: the main UIView (frontView) rotates & all of its elements resize properly, but the secondary/subview UIView (backView) does not rotate & all of its elements do not resize properly. Does anyone have suggestions on how to make the secondary UIView autoresize properly according to the rules I have set in Interface Builder?
views:
139answers:
2
A:
If I understand correctly, at the time of rotation 'backView' has been removed from it's superview, yeah? If so, that's the cause of the problem. The autoresize property determines how the view resizes relative to it's superview. If it doesn't have a superview it won't resize.
Perhaps using [backView setHidden:YES] instead of [backView removeFromSuperview] will be sufficient for your needs.
imaginaryboy
2010-08-25 05:22:38
Unfortunately, this happens even when backView is in the superview too. And I just tried out your suggestion to use `[backView setHidden:YES]` and it didn't do the trick either.
Jason
2010-08-25 05:35:37
Is backView.autoresizesSubviews == YES? Presumably it would be since it's the default, but so far that's the only other thing I can think of.
imaginaryboy
2010-08-25 05:42:14
Yes, it is equal to YES.
Jason
2010-08-25 14:21:55
Is there a code sample you can post that actually exhibits the incorrect behavior?
imaginaryboy
2010-08-25 14:44:33
A:
In the end, the solution I found was simply to separate my UIViews into separate UIViewControllers, and make sure that any views that I wanted to be able to rotate only had one UIView.
Jason
2010-10-18 03:20:17