IPhone-landscape-application

Using the information here: An application for use only for iPhone landscape websites ... I can only launch, use and maintain my view as a landscape. However, I am confused about the axis.

The absolute axis behaves as expected, the value (0,0) is the upper left, (240,0) is the upper center, (0,320) is the lower left corner, etc. However, when I try to perform calculations related to the view in which I will describe, I find x, y oriented, as if the top left portrait were the source. Therefore, to draw something at the center point of my controller, I need to do:

CGPoint center = CGPointMake(self.view.center.y, self.view.center.x); 

I guess this is because the UIView that my self.view controllers refer to gives it values โ€‹โ€‹relative to it, spanning the frame, that is, a window that has an axis start in the upper left corner in portrait mode.

Is there any easy way to account for this that I am missing?

The documentation assumes that the transform property is exactly what I am looking for, however I am experiencing further confusion here. There are 3 main properties:

  • frame
  • Borders
  • Center

If I do this in viewDidLoad:

 // calculate new center point CGFloat x = self.view.bounds.size.width / 2.0; CGFloat y = self.view.bounds.size.height / 2.0; CGPoint center = CGPointMake(y, x); // set the new center point self.view.center = center; // Rotate the view 90 degrees counter clockwise around the new center point. CGAffineTransform transform = self.view.transform; transform = CGAffineTransformRotate(transform, -(M_PI / 2.0)); self.view.transform = transform; 

Now, according to the reference docs, if the transform is not set to an identity transform, self.view.frame is undefined. So I have to work with borders and center.

self.view.center is now correct because I installed it the way I wanted. self.view.bounds remains unchanged. I believe that self.view.frame is exactly what I want, but, as noted above, the link states that it is invalid.

Therefore, when I can get what I think is the right number, I am afraid that I am losing sight of something critical that will later become unpleasant.

Thanks.

+6
iphone uiviewcontroller landscape
source share
1 answer

With quartz 2D, the coordinate system has a coordinate origin (0,0) in the lower left corner of the graph, and not in the upper left corner. Perhaps this is not enough for you.

See: http://developer.apple.com/documentation/graphicsimaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html#//apple_ref/doc/uid/TP30001066-CH202-CJBBAEEC

+2
source share

All Articles