view - Load XIB into ViewController Xamarin? -
it possible create , load view custom xib in xamarin? in objective-c like:
self.viewcontroller = [[viewcontroller alloc] initwithnibname:@"viewcontroller" bundle:nil]; self.window.rootviewcontroller = self.viewcontroller;
1 - create xib file (example myview).
2 - in .cs related xib file add static creator method:
partial class myview : uiview { public myview (intptr handle) : base (handle) { } public static myview create() { var arr = nsbundle.mainbundle.loadnib ("myview", null, null); var v = runtime.getnsobject<someview> (arr.valueat(0)); return v; } }
3 - add myview
viewcontroller
:
public partial class viewcontroller : uiviewcontroller { myview v; public viewcontroller (intptr handle) : base (handle) { } public override void viewdidload () { base.viewdidload (); v = myview.create(); v.frame = view.frame; view.addsubview (v); } }
you can read more here.
Comments
Post a Comment