1

我正在使用 MonoDevelop 3.0.3 和 Monotouch 5.2.12

为什么在 iOS 5.1 中从未调用过“UISplitViewController”类中的“ShouldHideViewController”?

如果我没有分配“ShouldHideViewController”和“将显示/隐藏”属性,左/主视图会正确显示,但我无法在主视图(viewFees)中隐藏/显示“BarButtonItem”。

以下是我的拆分视图类代码:

using System;
using MonoTouch.UIKit;

namespace PlazaTimePad 
{
  public class FeesSplitViewController : UISplitViewController
  {
    CalendarMonthViewController viewCalendar;
    FeeListViewController viewFees;

    public FeesSplitViewController () : base()
    {
      this.TabBarItem.Title = "My Time"; 
      viewFees = new FeeListViewController ();
      viewCalendar = new CalendarMonthViewController (viewFees);

      ViewControllers = new UIViewController[] {viewCalendar, viewFees};

      WillHideViewController += (object sender, UISplitViewHideEventArgs e) => {
        viewFees.AddContentsButton (e.BarButtonItem);
      };

      WillShowViewController += (object sender, UISplitViewShowEventArgs e) => {
        viewFees.RemoveContentsButton ();
      };

      ShouldHideViewController += (svc, viewController, inOrientation) => {
        return inOrientation == UIInterfaceOrientation.Portrait || 
               inOrientation == UIInterfaceOrientation.PortraitUpsideDown;
      };
    }
  }
}
4

1 回答 1

0

我认为你应该重写WillRotate或者DidRotate你正在尝试做的事情。

这是链接:

http://docs.go-mono.com/index.aspx?link=M%3AMonoTouch.UIKit.UIViewController.WillRotate(MonoTouch.UIKit.UIInterfaceOrientation%2CSystem.Double )

http://iosapi.xamarin.com/index.aspx?link=M%3AMonoTouch.UIKit.UIViewController.DidRotate(MonoTouch.UIKit.UIInterfaceOrientation )

如果您使用本机帮助浏览器(帮助菜单 -> 帮助)浏览这些文档,您将获得与 C# 集成的完整 Apple 文档。

于 2012-06-13T12:24:55.393 回答