Monotouch:UINavigationController,设置RootViewController

发布于 2024-10-27 20:05:24 字数 635 浏览 1 评论 0原文

如何在 Monotouch 中映射 initWithRootViewController Objective-C 方法?

从 Miguel de Icaza Rosetta 网站上,我找到了以下翻译,但我不知道如何应用它:

Selector: initWithRootViewController:
Method: IntPtr Constructor (UIViewController rootViewController);

然后,我还有另一个问题需要解决。我会在运行时更改 UINavigationController RootViewController。是否可以?网上冲浪,我发现了这个 更改 UINavigationController 的根视图控制器。有更简单的解决方案吗?

先感谢您。

编辑:我的目标是在 Monotouch 中映射 initWithRootViewController 方法(在链接中提供)。

How is it possible to map the initWithRootViewController objective-c method in Monotouch?

From Miguel de Icaza Rosetta site, I've found the following translation but I don't know how to apply it:

Selector: initWithRootViewController:
Method: IntPtr Constructor (UIViewController rootViewController);

Then, I also have another problem to solve. I would change the UINavigationController RootViewController during runtime. Is it possible? Surfing the Web, I've found this Changing a UINavigationController’s Root View Controller. Is there a more simple solution?

Thank you in advance.

Edit: my goal is to map the initWithRootViewController method (provided in the link) in Monotouch.

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

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

发布评论

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

评论(1

情话已封尘 2024-11-03 20:05:24

要回答您的第一个问题 - 您只需创建一个新的 UINavigationController 如下:

UINavigationController navController = new UINavigationController(rootViewController);

从技术上讲,可以通过修改 ViewControllers 属性来更改根控制器。例如:

navController.ViewControllers = new UIViewController[2] { newRootController, childController }

编辑

尝试将以下构造函数添加到您的自定义UINavigationController

public CustomNavController(UIViewController rootViewController)
{
    ViewControllers = new UIViewController[1] { rootViewController };
}

我不确定这是否是完成它的最佳方法,但它会起作用。

To answer your first question - you simply create a new UINavigationController as below:

UINavigationController navController = new UINavigationController(rootViewController);

Technically it would be possible to change the root controller by modifying the ViewControllers property. For example:

navController.ViewControllers = new UIViewController[2] { newRootController, childController }

EDIT

Try adding the following constructor to your custom UINavigationController:

public CustomNavController(UIViewController rootViewController)
{
    ViewControllers = new UIViewController[1] { rootViewController };
}

I'm not sure if this is the best way to get it done, but it'll work.

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