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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -