In advance, I apologize as I would say that I'm a beginner with iOS programming.
I want to use UIScrollView
because the content to display exceed the height of the screen.
Therefore, I would like only a vertical scroll and not a horizontal scrolling.
I'm using the Storyboard to draw the views with AutoLayout
.
Here's are the screenshot of my UIViewController
with the UIScrollView
:
Then I change the Label to a big text like that
override func viewDidLoad() {
super.viewDidLoad()
self.label1Label.text = "Seize jours après la chute du président Blaise Compaoré, le Burkina Faso a un nouveau chef d'EtatA l'issue d'ultimes tractions, civils et militaires se sont accordés, lundi 17 novembre, sur le nom du diplomate Michel KafandoSeize jours après la chute du président Blaise Compaoré, le Burkina Faso a un nouveau chef d'EtatA l'issue d'ultimes tractions, civils et militaires se sont accordés, lundi 17 novembre, sur le nom du diplomate Michel Kafando"
self.label1Label.numberOfLines = 0
self.label1Label.sizeToFit()
My problem is that if I don't set manually a width for my contentView (inside the UIScrollView
), the scrolling is horizontal, not vertical. (Look Screenshot below):
I've tried to set contentSize as I've seen in many google post but without success :
self.scrollView.contentSize = CGSizeMake(400.0, 600.0)
If I set a width manually for my contentview (i.e : 320pts
), the scrolling will be vertical (GOOD) but then depending on the iphone size, it won't cover the whole width of the screen as shown in the following screenshot :
The question is : what is the correct implementation to use UIScrollView
to have a contentView
that respect the autolayout constraint (full screen : 0top - 0bottom - 0left - 0right
) and the scrolling to be only vertical.
Thanks a lot for your help!