我有这个......
public partial class ViewController : UIViewController
{
UIView[] seqPages;
...
}
private void loadApp()
{
int seqCount=5;
for (int i = 0; i < seqCount; i++)
{
seqPages[i] = new UIView()
{
Frame = new CoreGraphics.CGRect(0, 0, vpWidth, vpHeight)
};
string s = app.sequence[i];
var img = UIImage.FromFile("pages/myimg.png");
UIImageView imgView = new UIImageView(new CoreGraphics.CGRect(0, 0, 1000, 1000));
imgView.Image = img;
imgView.ContentMode = UIViewContentMode.ScaleAspectFit;
seqPages[i].Add(imgView);
mainContainer.Add(seqPages[i]);
}
}
private void removePage(index){
//Remove the children of seqPages UIVIew array
}
所以,在注释“//删除seqPages UIVIew数组的子节点”我需要类似的东西:seqPages [index] .removeAllChildren();
我无法在Google上找到如何归档此内容。有谁能够帮我 ?
答案 0 :(得分:2)
UIView
有一个RemoveFromSuperview
方法会将其从“父级”中删除:
foreach (var view in this.View.Subviews)
{
view.RemoveFromSuperview();
}