views:

37

answers:

1

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!

+1  A: 

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.

Run Loop
What is the syntax for adding an initialized label to the scroll view?
Robert Eisinger
[scrollView addSubview:myLabel];
Run Loop