I am not grasping how coordinates work in a rotated iPhone app, and I'm
hoping someone will explain them.

My goal is a scroll view consisting of two equal "pages" side by side with
the iPhone sideways (landscape). I have accomplished this, but I don't
understand how I did it; I used pure trial and error, and what works makes
no sense to me. Here's what I did.

The scroll view occupies the entire window (except for the status bar, of
course). It has a view controller implemented so as to permit the
autorotation, and the plist tells us to start up in landscape mode. And we
do. So far so good.

Now I populate the scroll view. I want its content to be double-wide, but I
have to widen its *height* (svc is the scroll view's controller):

    CGRect f = svc.view.frame;
    CGSize sz = CGSizeMake(f.size.height * 2.0, f.size.width); // swap!
    ((UIScrollView*)svc.view).contentSize = sz;

Now I place the first page content:

    CardController* cc =
     [[CardController alloc] initWithCard: [data objectAtIndex: 0]];
    svc.view.frame = f; // don't swap!!
    [svc.view addSubview:cc.view];

Now I place the second page content:

    f.origin.x += f.size.height; // ??? height and width are swapped...
                                 // but x and y are not swapped?????
    CardController* cc2 =
     [[CardController alloc] initWithCard: [data objectAtIndex: 1]];
    cc2.view.frame = f;
    [svc.view addSubview: cc2.view];

This works great. But why? What on earth is going on here? Thanks - m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



_______________________________________________

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