On Wed, 06 Apr 2011 05:25:34 -0400, Jeffrey Walton <noloa...@gmail.com> said:
>Unfortunately, I don't know what I am looking for. Hence the reason I
>want to follow instructions. The best I can tell, the documentation is
>written for folks who have experience with the library (folks like
>you), and not folks who need steps detailed (folks like me).

I completely agree, and I think you *should* know what you're looking for. 
That's why my book *explains* scroll views to you rather than just giving you 
blind instructions to follow or parroting the documentation, plus by the time 
you get to them you understand the *concepts* on which they are based.

It is a *lot* easier to understand scroll views if you create and populate them 
in code before dealing with scroll views in the nib. So I suggest you scrap 
what you've got and start with this:

UIScrollView* sv = [[UIScrollView alloc] initWithFrame:
                    [[UIScreen mainScreen] applicationFrame]];
self.view = sv;
CGFloat y = 10;
for (int i=0; i<30; i++) {
    UILabel* lab = [[UILabel alloc] init];
    lab.text = [NSString stringWithFormat:@"This is label %i", i+1];
    [lab sizeToFit];
    CGRect f = lab.frame;
    f.origin = CGPointMake(10,y);
    lab.frame = f;
    [sv addSubview:lab];
    y += lab.bounds.size.height + 10;
    [lab release];
}
CGSize sz = sv.bounds.size;
sz.height = y;
sv.contentSize = sz; // This is the crucial line
[sv release];

You'll need a view-based app to start with; put that in the loadView method 
(not viewDidLoad), so that the scroll view *is* the view controller's view. The 
crucial move, as the comment notes, is that we tell the scroll view how large 
its content view is to be. If we omit this step, the scroll view won't be 
scrollable; the window will appear to consist of a static column of labels.

m.

--
matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to