2

I am making an application for iOS in swift using Xcode. I have designed a user interface for the settings page of the app. The pictures show the preview rendering in Xcode:

Portrait

Landscape

I.e. the content height is too large for certain devices. Is there any way to make the content scrollable when the height of the content exceeds the height of the view? I have tried a scroll view but because of the constraints of the layout (some of the elements are aligned along the right edge of the screen) I couldn't get it to work for me.

adam
  • 23
  • 4
  • UIScrollView is def. the way to go. Your constraints should not be an issue, make sure the constraints are set to the UIScrollView itself and not the parent UIView. If you're still having issues YouTube a UIScrollView tutorial but that's definitely the easiest way to accomplish what you want and also a VERY useful thing to learn how to use in general. Even if you go with a different route you should still look up how to properly do this for future reference. – Albert Renshaw Jan 09 '16 at 19:33
  • Thanks Albert, I'll have another look into it. I had been setting the constraints so the the text boxes were 8 pixels from the right side of the UIScrollView, but they were disappearing for some reason. I think it could be because I haven't properly defined the width of the scroll view. – adam Jan 09 '16 at 19:37
  • check out my answer for same issue. this might help you. http://stackoverflow.com/questions/12846351/uiscrollview-contentsize-not-working/37653424#37653424 – Vatsal Shukla Sep 23 '16 at 07:34

1 Answers1

1
First you have to get the last object from your scrollview.
i.e :- your last object is changePassword so first you have create        IBOutlet of changePassword ,

For example if you create outlet with name like btnChangePassword then write in your viewDidLoad :

let contentHeight: CGFloat = btnChangePassword.frame.origin.y +     btnChangePassword.frame.size.height 
if(contentHeight > UIScreen.mainScreen.bounds.height)
{
      yourScrollView.contenSize   =CGSizeMake(screenWidth,contentHeight)
}
Mitesh Mistri
  • 439
  • 2
  • 8