0

I Have a ViewController that I want to display over another viewController (like a popup), so I use this code:

MyViewController vc = new MyViewController();           
this.View.AddSubview(vc.View);

And it works fine, but I am not sure to unload it correctly since I am not able to interact with the background view anymore, I use this code (from the MyViewController class) to unload it:

foreach (UIView view in this.View.Subviews) {
    view.RemoveFromSuperview();
}

How can I remove the subview within the second viewcontroller itself and enable the first view again?

Thanks!!!

4

1 回答 1

0

以上是一个非常糟糕的主意。

如果您正在创建一个新的 View Controller,您应该展示 View Controller,而不是落后于该 View Controller 的视图并在其他地方管理它们。

所以你应该展示你的视图控制器,要么推送它,要么以模态方式激活它。细节取决于您包含的视图控制器的细节。

于 2013-02-15T18:57:20.447 回答