Re: pls explain rotated iPhone coordinates to me
Re: pls explain rotated iPhone coordinates to me
- Subject: Re: pls explain rotated iPhone coordinates to me
- From: Alexander Spohr <email@hidden>
- Date: Tue, 15 Dec 2009 12:31:59 +0100
This seems wrong.
When do you call this code?
Usually it is just enough to set the springs of your scroll view in IB. Then, after rotation, refit your content.
atze
Am 15.12.2009 um 03:46 schrieb Matt Neuburg:
> 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.
>
_______________________________________________
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