Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a UIViewController to UIScrollView

I have a UIViewCOntroller and i have added a lot of UI components to it, labels, text fields, etc..

Now, i need to add some more fields to it. and i have figured out that i don't have any space in my viewcontroller to add any. So i was thinking of adding a scrollView to solve this problem. Is there away where i could add my UIViewController which is holding all the UI components to a UIScrollView.

How can i do this programatically ?

like image 349
Illep Avatar asked Mar 15 '26 02:03

Illep


1 Answers

For exemple if you are in A viewController methode :

UIViewController * v =  [[UIViewController alloc] init];
UIScrollView * sc =  [[UIScrollView alloc] init];

...use setFrame for v and sc frames

[sc setScrollEnabled:YES];
[sc setContentSize:2000];
[sc addSubview:v.view];

[self.view addSubview:sc];
like image 167
Beber Avatar answered Mar 17 '26 14:03

Beber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!