简体   繁体   中英

UIScrollView don't go all over the screen when trying to pin it to the bottom of the superview

I'm trying to fix keyboard content covering bug with UIScrollView in my simple learning app. Keyboard didn't cover my textfield, but it covered my other content. So I have textfield at the bottom of the screen, and I placed UIScrollView underneath. I set the following constraints to scrollview:

Scroll View.top = TextField.bottom +5
trailing = Scroll View.trailing
leading = Scroll View.leading
Bottom Layout Guide.top = Scroll View.bottom

And inside scrollview I have UIView with all my content. That UIView is pinned to scroll view's edges (leading, trailing, top and bottom) and have equal width with View. So it looks fine on 4 inch display, like so: iPhone 4 inch

But on bigger screen it don't go all over the screen. Here is the screenshot: iPhone 5.5 inch

It gets even worse on iPad. So I don't get any idea why this weird things are happened. Can anyone help me?

I have seen issues like this when you dealt with autolayout. I would recommend you to check below points.

  1. Please check whether scrollview contentsize is equal to height of UIView inside the scrollview.
  2. Make sure you have constraints in all the UIcomponenents inside the scrollview.
  3. Also check whether any height constraints are present in scrollview or inner container View/tableview ie explicitly set height contraints in tablview height etc.
  4. UIView bottom constraint to scrollview should be equal to property.
  5. Enable exception breakpoint in xcode project and check whether you get any autolayout expception in xcode console while running the app.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM