Monotouch在纵向/横向中旋转视图 [英] Monotouch rotate view in Portrait/Landscape

查看:164
本文介绍了Monotouch在纵向/横向中旋转视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以举例说明如何将单点触控应用程序的视图从纵向旋转到横向,反之亦然?

Can anyone give an example of how to rotate the view of a monotouch application from portrait to landscape and vice versa?

推荐答案

如果在Interface Builder中设置ui元素的几何图形,请确保在Size Inspector(Cmd + 3)中设置自动调整大小属性。然后,您可以通过单击Interface Builder中视图标题栏左上角的旋转按钮来查看旋转后视图的外观。

If you set the geometry of your ui elements in Interface Builder, then make sure you set the Autosizing attributes in the Size Inspector (Cmd+3). You can then see how the view will look after rotating by clicking the little "Rotate" button in the upper left of the title bar of your view in Interface Builder.

一次你已完成所有设置,只需在ViewController中覆盖以下方法:

Once you have all that set up, just override the following method in your ViewController:

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
    return true;
}

现在在模拟器中,您可以旋转所需的所有内容,您的UI将自动旋转-adapt。

Now in the simulator, you can rotate all you want and your UI will auto-adapt.

这篇关于Monotouch在纵向/横向中旋转视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆