gpt4 book ai didi

c# - Xamarin Monotouch UISplitViewController : How can I set or create the delegate for UISplitViewController?

转载 作者:行者123 更新时间:2023-11-29 04:03:47 26 4
gpt4 key购买 nike

我有一个 UISplitViewController,并尝试从 MasterViewController 获取事件并完全更改 DetailViewController。据我了解,这基本上可以通过执行以下操作来完成:

ViewControllers[1] = new MyNewViewController();

当我这样做时,什么都没有改变!我知道这与设置委托(delegate)有关,但我不知道在哪里以及如何执行此操作。

最佳答案

重写 UISplitViewControllerDelegate 来执行任何需要执行的操作。我的一个应用程序的示例:

using System;

using MonoTouch.UIKit;

namespace PythonMath
{
class SplitViewControllerDelegate : UISplitViewControllerDelegate
{
public override bool ShouldHideViewController(
UISplitViewController svc,
UIViewController viewController,
UIInterfaceOrientation inOrientation)
{
return (! InAppPurchaseModel.Editor.Purchased) ||
inOrientation == UIInterfaceOrientation.Portrait ||
inOrientation == UIInterfaceOrientation.PortraitUpsideDown;
}
}
}

然后将其分配给 UISplitViewController 的委托(delegate):

var SplitViewController = new UISplitViewController();
SplitViewController.Delegate = new SplitViewControllerDelegate ();

关于c# - Xamarin Monotouch UISplitViewController : How can I set or create the delegate for UISplitViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15504522/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com