I need a UIScrollview
to show some static content in my app. I have taken a UIScrollView
through XIB
and started adding some UIImageView
s and textViews in to it. But after coming to the end of the scrollView the view is not exapanding anymore. I need more space so that I can add some more views below. Is there any way in which I can do this (through XIB
and not through code).
I struggled a lot to get this done in a more elegant way then the solution described by Csabi. It's really simple:
In your xib file just add a generic view which is not a subview of your viewController.view (i.e although this view is in your xib file, it is not a part of your viewController's view hierarchy.)
Then select this view and using size inspector set the width and height that suits your need. Add whatever objects you want to this view. Hook up this view to your viewController with an IBOutlet. (Let's call it IBOutlet UIView *myBigView).
in your viewController.view drag a ScrollView and adjust the size of the scroll view as you like. Hook this up to your viewController. (IBOutlet UIScrollView *scrollView)
Now it's super simple:
-(void) viewDidLoad{
[super viewDidLoad];
self.scrollView.contentSize = self.myBigView.bounds.size;
[self.scrollView addSubview:self.myBigView];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With