Unboxing iOS: how you edit the content view more than the screen in UIScrollView

I have a view that is larger than the screen, I need to put it in a UIScrollView.

So, I first add the UIViewController to the storyboard, then add the UIScrollView to the root view of my view controller, and then when I add subviews from the UIScrollView, but I cannot add them outside the scrollview area, can I see how to solve this problem?

+5
source share
3 answers

Change the simulated size of the view controller to Freeform, and then you can set the size as you wish. After editing, you can install it back.

freeform

+10
source

Change 1:

1) put your subview in the visible scrollable area

2) change the frame of the new subtitle as you wish

change frame

3) change the contentSize property of the scrollview property with runtime attributes

runtime attributes

Edit 2: u can create a new view with xib that contains all your routines, and then add that view to scrollview. Or you can use the Container View layout as follows:

enter image description here

ps: don't forget about contentSize (point 3 in my first edit), but if you use automatic linking, you need to set it programmatically as follows:

- (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; _scrollView.contentSize = CGSizeMake(320, 250); } 
+1
source
  • enter the scroll view in the view controller and put the view in the scroll view called containerView.
  • create large content in another view controller (named bigContentView)
  • in code, view the download event,

a. get bigContentView on Id storyboard. (get controller and use controller.view)

b. create an output in the container view.

from. refresh containerView frame according to your requirement (update width and height)

e. bigContentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

e. containerView addSubView: bigContentView.

0
source

Source: https://habr.com/ru/post/1201880/


All Articles