Inside a UIViewController
, I need to have the bottom half scrollable. So I added a UIScrollView
and positioned it halfway down the view's height. And in the viewDidAppear
method, I have put the below two code lines to make it scrollable.
self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.scrollView.frame.size.height);
self.scrollView.frame = self.view.frame;
This way works if the scroll view fills the entire view, I've tested. But this method didn't work for my need. The scroll view would automatically move up and take up the entire screen. I assumed it was the second line of code which causes this.
So I removed the scroll view, added two UIView
s to the view controller. To the bottom view, I added the UIScrollView
. And in the viewDidAppear
method, I have put the same two code lines changing the second line to refer the frame of the UIView
that contains the scroll view..
self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.scrollView.frame.size.height);
self.scrollView.frame = self.containerView.frame;
But it wouldn't scroll either.
Can anyone please tell me how to do this correctly?
Thank you.