Xamarin.ios 需要有关UITabBarController和方向的帮助吗

Xamarin.ios 需要有关UITabBarController和方向的帮助吗,xamarin.ios,uitabbarcontroller,Xamarin.ios,Uitabbarcontroller,我有一个应用程序(使用MonoTouch编写,目前正在运行),我想添加横向方向。我使用的是一个超级阿巴斯控制器 我不知道如何创建一个允许我重写“ShouldAutorotate…”方法的控制器。有人能给我举一个例子,在MonoTouch中使用UITabBarController吗?您是否在子类化UITabBarController 您可能没有子类化,只是在Interface Builder中添加了一个普通的控制器。您必须使用子类重写该属性 首先创建一个新类,如下所示: //Test this,

我有一个应用程序(使用MonoTouch编写,目前正在运行),我想添加横向方向。我使用的是一个超级阿巴斯控制器


我不知道如何创建一个允许我重写“ShouldAutorotate…”方法的控制器。有人能给我举一个例子,在MonoTouch中使用UITabBarController吗?

您是否在子类化UITabBarController

您可能没有子类化,只是在Interface Builder中添加了一个普通的控制器。您必须使用子类重写该属性

首先创建一个新类,如下所示:

//Test this, it's off the top of my head
[Register("YourTabController")]
public class YourTabController : UITabBarController
{
    public YourTabController (IntPtr handle) : base (handle) { }

    [Export("initWithCoder:")]
    public YourTabController (NSCoder coder) : base (coder) { }

    //Override should rotate
    public bool ShouldAutoRotateToInterfaceOrientation(UIInterfaceOrientation o)
    { return true; }
}

然后,如果IB中已有UITabBarController,则有一个“Class”属性可设置为新类的名称。

TweetStation包含此设置的示例,并向下传播所有嵌套视图控制器的旋转