pls explain rotated iPhone coordinates to me
pls explain rotated iPhone coordinates to me
- Subject: pls explain rotated iPhone coordinates to me
- From: Matt Neuburg <email@hidden>
- Date: Mon, 14 Dec 2009 18:46:09 -0800
- Thread-topic: pls explain rotated iPhone coordinates to me
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 = email@hidden, <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 (email@hidden)
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:
This email sent to email@hidden