I am having trouble in fixing a problem with my iPad app.
I am loading a photo view controller when pressing a button on my main view controller.
In portrait mode the view controller loads fine, but when I load it in landscape mode my picture looks wrong:
I want it to look like:
I have narrowed down the problem to the following call:
- (CGRect)frameForPageAtIndex:(NSUInteger)index {
CGRect bounds = pagingScrollView.bounds;
CGRect pageFrame = bounds;
pageFrame.size.width -= (2 * PADDING);
pageFrame.origin.x = (bounds.size.width * index) + PADDING;
return pageFrame;
}
I’ve been trying to switch from pagingScrollView.bounds to pagingScrollView.frame but no go. pagingScrollView.bounds is a subview of my view. I just don’t know how I can get it to recognize the orientation.
NOTE: When I rotate the device the problem fixes it self.
You need set the appropriate values for the
autosizingMaskproperty of your views.If you are using a xib file, play around with the size inspector in interface builder (second right most tab on the Utilities panel in XCode 4.2)