I am busy creating a view from scratch and have run into a problem I have never run in to before. I am developing on a 4 inch retina screen on an app that is landscape mode only. The problem I am having is that the width of the view is 568 points (as it should be), but if I place an item at xpos 280 points, it is half off the screen!

The code I am using to create the frame is is:

CGRectMake(280, 9, 100, 13);

Here is a screenshot of the result. The view in question has a red background color and is off the screen on the right: http://cl.ly/image/2U333e1W300l

*Edit - the width in this case seems to be 284 points, which is exactly half of 568 (the supposed width). So it seems the width is only half of what it should be... strange

有帮助吗?

解决方案 3

I finally discovered the answer.

The problem was that I was not initialising the app to startup in landscape mode properly. After following the instructions in this post: Landscape Mode ONLY for iPhone or iPad . My problem was solved

其他提示

When you use this:

CGRectMake(280, 9, 100, 13);

You use points, not pixel.

1 point = 2 pixels.

The width of the screen is 320 points. Therefore, your view is placed 40points (80 pixels) before the view ends.

Probably auto-layout (autoresizing mask's) moves the view. Can you set frame explicitly for the view after rotation? If it will work, then you should take a look to auto-layout (or auto-resizing mask's).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top