MonoTouch 的 UIViewControllerHierarchy 不一致异常

发布于 2024-12-11 09:34:58 字数 548 浏览 0 评论 0原文

我已经升级到 iOS 5,并安装了 MonoTouch 2.8 和其他相关更新。我有一个 UIViewController,其中有一个 UITabBarController,并为视图配置了两个不同的 XIB。 UITabBarController 上还有一个插座。我在 ViewDidLoad 中所做的事情

this.View = this.TabBar.View;

现在升级到 iOS 5,我在选项卡栏中的视图中遇到了 UIViewControllerHierarchyInconsistency 异常。我可以执行

this.View.AddSubview(this.TabBar.View); 

or

this.View.Add(this.TabBar.View);

操作,异常就会停止发生。但问题是我的标签栏位于屏幕底部,只有部分图像可见,并且您看不到相关文本。在搜索中,我发现了一些 Objective-C 示例,它们看起来都在使用子视图路由,这没有帮助。有什么想法吗?

I've upgraded to iOS 5 with MonoTouch 2.8 and other related updates. I've got a UIViewController that has a UITabBarController in it with two different XIBs configured for the view. Also have an outlet on the UITabBarController. What I was doing in the ViewDidLoad is

this.View = this.TabBar.View;

Now with the upgrade to iOS 5 I'm getting a UIViewControllerHierarchyInconsistency exception with the views in the tab bar. I can do

this.View.AddSubview(this.TabBar.View); 

or

this.View.Add(this.TabBar.View);

and the exception stops happening. The trouble though is that my tab bar becomes positioned at the bottom of the screen where only part of the image is visible and you cannot see the associated text. In the searching I did I found a few Objective-C examples, which all look like they are using the subview route, which doesn't help. Any ideas?

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

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

发布评论

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

评论(1

舂唻埖巳落 2024-12-18 09:34:58

iOS4 中支持的模式是一个坏主意:您通过获取内部(视图控制器的 View 属性)来连接视图控制器,并将其添加到另一个视图控制器的视图层次结构中。这不仅丑陋,而且引发了有关视图层次结构的各种问题。

尽管Apple仍然支持基本模式,但不再支持任何高级用户,并且您需要使用新的视图控制器包含设置。这些无效使用现在作为例外提出。

在 WWDC 2011 演示中,查找会话 102 - “实现 UIViewController Containment”。

主要的变化是,对于您的主视图控制器,将占据整个屏幕的控制器,您将旧的更改

window.AddSubview (myViewController.View);

window.RootViewController = myViewController

:对于其他人,您使用新的 API:

currentContainer.AddChildViewController (myOtherViewController);

在您的情况下,您将向选项卡添加一个新的 ViewController,因此,您可以执行以下操作将视图控制器添加到第一个选项卡:

myTabBar.ViewControllers [1].AddChildViewController (myFancyController)

The supported pattern in iOS4 was a bad idea: you connected view controllers by grabbing an internal (the view controller's View property) and added it to another view controller's view hierarchy. This was not only ugly, but raised all kinds of questions about the view hierarchy.

Although Apple still supports the basic pattern, any advanced users are no longer supported, and you need to use the new viewcontroller containment setup. These invalid uses are now raised as exceptions.

In the WWDC 2011 presentation, look for Session 102 - "Implementing UIViewController Containment."

The major changes are, for your main view controller, the one that will occupy the whole screen, you change the old:

window.AddSubview (myViewController.View);

To:

window.RootViewController = myViewController

For others, you use the new API:

currentContainer.AddChildViewController (myOtherViewController);

In your case, you are adding a new ViewController to your tab, so you would do something like this for adding your view controller to the first tab:

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