如何在iPhone上横向绘制UIViewController?

发布于 2024-09-14 08:04:04 字数 476 浏览 8 评论 0原文

关于这个主题已经有一些问题。不幸的是,他们都没有帮助我。所以事情就是这样。我正在开发一款应用程序 atm,它有一个带有两个选项卡的 tabcontroller,其中包含彼此叠置的多个导航控制器。现在,在顶级导航控制器的一个选项卡中,我想以横向方向绘制一些图形。

不幸的是,使用返回 YES 的 shouldAutorotateToInterfaceOrientation 方法会导致无论如何都没有帮助。

现在我想知道是否可以隐藏状态栏和导航栏,然后绘制图形,使其看起来像横向。但后来我还想添加一些标签。我很确定我也可以将它们旋转 90 度。但这可能不是正确的方法。我想有一天提交我的应用程序......

所以现在我希望有人知道这里最好的方法是什么以及如何实现它。

谢谢。

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 orientation. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我最亲爱的 2024-09-21 08:04:04

我在其他地方找到了解决方案。这个想法是使用 CGAffineTransform 方法。它允许您转换 uiview 的完整坐标系。下面的代码将其旋转为横向。现在,当您绘图时,绘图与旋转的坐标系相关,并且所有内容都是以横向方向绘制的。

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

这就是我想要的。但无论如何,如果还有其他建议,请留言!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文