How to configure dynamic dynamics of UIScrollview using programming

I used UIScrollview in my iPhone app . I set the default size of UIScrollview 320 * 548 . I want to dynamically increase the height of a UIScrollview using programming, but I have not succeeded so far. I used below code

  CGRect scrollFrame; scrollFrame.origin = _tblScroolView.frame.origin; scrollFrame.size = CGSizeMake(320, 700); _tblScroolView.frame = scrollFrame; 

Please help me

Thanks!

+7
source share
3 answers

To change the scroll size

 scrollView.frame = CGRectMake(originX, originY, width, height); 

To resize the scrollable area:

 scrollView.contentSize = CGSizeMake(width, height); 

version of Swift 3

 scrollView.frame = CGRect(x: scrollX, y: scrollY, width:width, height:height) scrollView.contentSize = CGSize(width:width, height: height) 
+9
source

run any function when you need to increase your scrollview, and then use this code in this function and make the desired size for scrollview

 scrollViewName.frame = CGRectMake(originX, originY, width, height); 

change scroll area

 scrollViewName.content.size = CGSizeMake(width, height);... 
+2
source
 int height = 600; for (i = 0; i<5; i++) { // do what you want. suppose you create a view which size is - 10,10,300,800. height = createdView.frame.size.height+10; } scrollView.contentSize = (320, height); 

Hope this helps you.

+1
source

All Articles