2012-09-14 24 views
0
子视图

目前我加载认为有一些子视图 与 NSBundle.MainBundle.LoadNib("NibName", this, null)功能 但比我手动与 this.AddSubviews(this.subview1)添加加载视图的子视图。负载的UIView与他的MonoTouch的

我怎样才能加载视图从笔尖,所以我不需要手动添加子视图到当前视图?

编辑: 现在我试图让LoadNib函数的结果:

var res = NSBundle.MainBundle.LoadNib("ViewX",this,null);

var betterRes = Runtime.GetNSObject(res.ValueAt(0)) as Viewx;

现在“这个”具有初始化的子元素的性质,但他的观点是空的。 和“betterRes”具有视图中的所有子视图,但子元素的所有属性均为null。 只是为了澄清...每个子元素是按钮或标签,并有自己的看法。

回答

0

如果我正确理解你想要什么:加载与插座或行动从笔尖文件主要观点来看,这里是一个尝试:

//Load the view 
var res = NSBundle.MainBundle.LoadNib("ViewX",this,null); 
// init your view with IntPtr 
var betterRes = new Viewx(res.ValueAt(0)); 
//then use this view as main view 
this.View = betterRes; //Or add subview: this.View.AddSubView(betterRes); 

现在,在你看来有些属性应该工作。
希望得到这个帮助!