CodeGuy
CodeGuy

Reputation: 28907

UIScrollView not showing

I have a simple ViewController that looks like this:

@interface MyViewController : UIViewController<UIScrollViewDelegate> {
   UIScrollView *scrollView;
   UILabel *label;
}
...
@property stuff
...

Now, what I'm trying to do with this Controller is have a ScrollView handle a really large label of text that I have. So in the viewDidLoad method of MyViewController.m I have:

scrollView.contentSize = CGSizeMake(1000,1000);
scrollView.delegate = self;
scrollView.clipsToBounds = YES;
[self.view addSubview:scrollView];

And I get a blank screen that I cannot scroll around on. It's just a white screen. Before adding the label part, I thought I would try to set up the scroll view first, and this is not even working. Shouldn't I see some scroll bars when I move my fingers around? How do I set up the scroll view so that it contains a label?

Thanks!

Upvotes: 0

Views: 2783

Answers (1)

RunLoop
RunLoop

Reputation: 20376

The scrollView wont be scrollable until you actually place content inside it which exceeds its frame. So, add your label to the scrollview and it should become scrollable.

Upvotes: 1

Related Questions