开发者

How to draw in UIViewController in landscape orientation on the iPhone?

开发者 https://www.devze.com 2023-01-11 15:47 出处:网络
there are already some questions on this topic. Unfortunately none of them helped me in anyway. So here is the thing. I am working on an app atm and it has one tabcontroller with two tabs, which conta

there are already some questions on this topic. Unfortunately none of them helped me in anyway. So here is the thing. I am working on an app atm and it has one tabcontroller with two tabs, which contain multiple navigationcontroller on top of each other. Now in one tab at the top level navigation controller, I want to draw some graphics in landscape orientation.

Unfortunately using the shouldAutorotateToInterfaceOrientation method returning YES does not help in anyway.

Now I was wondering whether I could just hide the statusBar and the navigationBar and then draw my graphics so that it looks like it is landscape ori开发者_如何学JAVAentation. But then I also would like to add some labels. I am quite sure I also could turn those around 90 degrees. But this is probably not the right approach here. And I want to submit my app someday...

So now I was hoping someone knows whats the best approach here and how to realize it.

Thanks.


I found a solution somewhere else. The idea is to use the CGAffineTransform method. It allows you to transform the complete coordinate system of a uiview. The piece of code underneath rotatets it to landscape. Now when you draw, the drawing relates to the rotated coordinate systems and everything is drawn in landscape orientation.

CGAffineTransform transform=CGAffineTransformIdentity;
transform=CGAffineTransformRotate(transform, (90.0f*22.0f)/(180.0f*7.0f));
transform=CGAffineTransformTranslate(transform, 80, 80);

This does what I want. But anyway, if there are any other suggestions, please post them!

0

精彩评论

暂无评论...
验证码 换一张
取 消