0

我在我的 monotouch 应用程序上设置了一个主视图。我设计了一个要导入到其中的局部视图(它在它自己的 XIB 文件中列出),并且控制器类能够拦截由局部视图控件生成的事件。

这可以做到吗?

4

1 回答 1

0

You can add Views inside other Views, but you probably want a ViewController for your inner view as well.

That's called UIViewController nesting, and handled, since iOS 5, with AddChildViewController(UIViewController innerVC). This only manage the lifecycle of the ViewController. You also have to add the inner View in your main View, like this.

//MainViewController.cs
public override void ViewDidLoad ()
{
    base.ViewDidLoad ();

    var innerVC = new InnerViewController ();
    AddChildViewController (innerVC);

    innerVC.View.Frame = new RectangleF (20, 20, 100, 100);
    Add (innerVC.View);
}

Read more on http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457

于 2013-07-02T08:16:23.750 回答