When iPad rotates scrollview not lined up with top of screen - ipad

When the iPad simulator changes orientation the contents of the uiscrollview no longer are aligned to the top. When the app starts in landscape all is well - the controls contained in the scrollview which should be the top most are at the top. The same is true when it starts in portrait.
However, when it is rotated there is a large gap at the top if it was from landscape to portrait or many of those at the top are off the top of screen if it rotates from portrait to landscape.
Does anyone have any ideas what I should be looking at in order to fix this, please?
Thanks

As Rob says - needed to make sure the UIScrollView is anchored top, bottom, left, and right with stretching in vertical and horizontal directions.

Related

UITextView in UIScrollview is below visible screen on iPhone 5S

I've an image and text view. Text view is pinned to the bottom, left and right to superview. On iPhone 11 text view visible as intended but on iPhone 5S it is hidden. On iPhone 5S I've to scroll up to see text view which is not what I want. I want text view to be visible at the bottom on all devices as it's pinned to bottom of superview. I can't figure out what is wrong. Below are screenshots of IB and device screenshots.
How to fix this issue?
If you want it to be visible regardless of the screen size, don't put it inside of the scrollview, put it outside. Right now it's constrained to its parent, which happens to be a view constrained to the scrollview, so it's positioned below, and you need to scroll to see it.

UITableView with autolayout does not fill screen in Landscape Mode. Why?

I have a UIViewController with a UITableView. The hosting UIViewController is presented by a UINavigationController. I am using autolayout and have used "Leading Space to Superview (-16.00)" and similar "Trailing Space to Superview Constraint" to pin the tableview to the left and right side of the parent view. It works great in Portrait mode. But when I switch to Landscape mode, the tableview is short by a few pixels on each side. Screen captures are shown below. Notice the small red border on the Landscape version. (I have set the background of the view, under the UITableview, to red.) I can even see this border in the storyboard, but I can't figure out how to get rid of it.
My app is built for iOS 10 if it matters.
Leading Space to Superview
I'm going to suggest that you've pinned the leading/trailing edges to the superview's margins. You want to pin them to the superview itself (and change the constant value to 0).

Switching to landscape, auto constraints in wrong corner

I'm presenting a view controller when my view controller is rotated to horizontal.
In my NIb, I have a help button with constraints to margin top and right of 8 pixels each. However, my view controller displays with the button in the top right of a Portait perspective. See image. How do I make this show up in top right in Landscape?
It looks like your screen did not rotate, because the status bar is still in portrait mode. BUT... even if it did rotate, you would probably have problems because the status bar is 8 pts wide, and it is automatically removed in landscape mode.
I'd say (1) set your constraints to put the button 30 or 40 pts from the corner, until you get the rotation stuff worked out, and (2) fix the rotation issues by looking at the settings for which rotations the simulator supports. Normally rotations allowed by xcode (at least for my default swift projects) are left, portrait, landscape, but not upside down.
It happens to me all the time, when using the simulator!
(Assuming that your project is supporting both landscape and portrait mode)
To make sure your device has rotated from landscape to portrait or the other way around, simply rotate it three times instead of once! (Press the ⌘ and then → three times)
Also for your button placement, I would recommend creating a Standard offset to superview's top and trailing margins, without using any particular numbers (Standard pops up when you delete the number in the constraint's Attribute Inspector).

iOS Auto Layout - How to have two stacked views in portrait move to side by side in landscape?

I am updating my app and want to allow landscape orientation.
I am wondering how I can take two views that are stacked on top of each other (and centered horizontally in container) while in portrait and move them to be side by side in landscape (and centered vertically in container).
I would like the bobblehead to be aligned on the left, and the quote box to be aligned on the right. Both views should take up full height while in landscape.
Here are some screen grabs:
What you want is having different layout when device size is not fit to your view.
In iOS8 you can do it without hard coding it.
Yes just by designing right constraint for right size class(introduce in XCode6)
Here is an example which doing same as you want
Example
Code
Download project
Output

Part of the screen disabled in landscape mode on view-based iPad app

I am developing an iPad application with view-based template in landscape mode as it has to share a toolbar to all its views and provide the functionality similar to tabbar.
The problem is that any control added to a portion of the screen on the right side is disabled. For example, if a button is added, the part of it on that portion of the screen doesn't work.
Surprisingly, the width of that portion of the screen is equal to the width of the screen in landscape subtracted by the width of the screen in portrait so I think the problem has something to do with that.
Thanks in advance
I'm betting those controls are outside the bounds of their superview (or the superview's superview, or the super-super-superview, or…). When the view hierarchy does a hit test, it returns nil if the point is outside its frame, so subviews outside the frame can't be hit. Note that views in IB don't have the "clips subviews" option on by default, so it's hard to tell where the view bounds are. Also check the autoresize settings on those views--if one of the containing views isn't set to resize horizontally and it's sized to portrait width in the nib, it won't expand to landscape width when you rotate the device.

Resources