I understood the operation of the UIScrollView
with AutoLayout , but in all cases I saw on the internet, I did not find a similar problem with this, maybe that's why the solutions are not working properly.
My scenario is this:
Scroll View
Content View
Login View
Where Login View I need a fixed width/height, vertically and horizontally center. And here the constraints that I set:
The problem is: when I rotate simulator (iPhone 6s) to landscape, I can't scroll and view everything because the content size of scroll view is 375 and my login box height is 420.
Is there something I'm missing for this particular scenario?
Your constraints should be like,
ScrollView
- top,bottom,leading,trailing
ContentView (UIView)
- top,bottom,leading,trailing,fixed height,horizontally center in container(center X)
LoginView
- fixed width,fixed height, horizontally center in container(center X) and vertically center in container (center Y)
try this small video tutorial that I created for you. It shows how to setup scrollview
that work for any ios device
+ work for any orientation
mode. tutorial is written in objective c
, but doesn't matter concept is same. less coding, just one method
+ autolayout.
link to the video tutorial --- > setup scrollview for any ios device + for any orientation mode in ios
hope this will help to you.try this and enjoy....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.