Custom iOS UIView Class MvvmCross Constraints - Draw(CGRect rect) Method Never Called -


i have situation cannot seem work out specific problem lies , i'm hoping little input.

i have simple view @ moment has uiscrollview. in viewdidload method register listen view models propertychanged event this:

public override void viewdidload() {     base.viewdidload();     viewmodel.propertychanged += viewmodel_propertychanged; }  private void viewmodel_propertychanged(object sender, system.componentmodel.propertychangedeventargs e) {     if (e.propertyname == "mycollection")     {         buildui();     } } 

when event fired kicks off building view since data available within view model. in buildui method have code:

view code

private void buildui() {     _mainscrollview = new uiscrollview(view.frame)     {         showshorizontalscrollindicator = false,         autoresizingmask = uiviewautoresizing.all     };      add(_mainscrollview);      view.subviewsdonottranslateautoresizingmaskintoconstraints();      view.addconstraints(         _mainscrollview.atleftof(view),         _mainscrollview.attopof(view),         _mainscrollview.withsamewidth(view),         _mainscrollview.withsameheight(view));         foreach(var ctx in viewmodel.mycollection)        {            var contextscorecontrol = new contextscoreview(new cgrect(100,100,100,100), ctx);            _mainscrollview.add(contextscorecontrol);             //var btn = viewhelpers.createdefaultbutton("test");            //_mainscrollview.add(btn);        }          _mainscrollview.subviewsdonottranslateautoresizingmaskintoconstraints();      var constraints = _mainscrollview.verticalstackpanelconstraints(new margins(20, 10, 20, 10, 5, 5), _mainscrollview.subviews);     _mainscrollview.addconstraints(constraints); } 

control code

[register("mycontrol")] public class mycontrol : uiview {     private myviewmodel _vm;      private uilabel _ctxtitle;      private uitextview _explanationtext;      private uislider _scoreslider;      public mycontrol(myviewmodel vm)     {         _vm = vm;         backgroundcolor = uicolor.cyan;     }      public mycontrol(intptr handle) : base(handle) { }      public mycontrol(cgrect rect, myviewmodel vm)     {         _vm = vm;         backgroundcolor = uicolor.cyan;     }      public mycontrol(cgrect rect) : base(rect)     {         backgroundcolor = uicolor.cyan;     }      public override void draw(cgrect rect)     {         base.draw(rect);          _ctxtitle = viewhelpers.createtitlelabel();         _ctxtitle.text = _vm.text;          _explanationtext = viewhelpers.createautoexpandingreadonlytextview();         _explanationtext.text = _vm.scoringhint;          _scoreslider = viewhelpers.createdefaultslider();         _scoreslider.value = _vm.score;          addsubview(_ctxtitle);         addsubview(_explanationtext);         addsubview(_scoreslider);          this.addconstraints(             _ctxtitle.attopof(this, iosconstants.uipadding),             _ctxtitle.atleftof(this, iosconstants.uipadding),             _ctxtitle.withsamewidth(this).minus(iosconstants.uipadding * 2),              _explanationtext.below(_ctxtitle, iosconstants.uipadding),             _explanationtext.withsameleft(_ctxtitle),             _explanationtext.withsameright(_ctxtitle),              _scoreslider.below(_explanationtext, iosconstants.uipadding),             _scoreslider.withsameleft(_explanationtext),             _scoreslider.withsameright(_explanationtext),             _scoreslider.atbottomof(this)              );     } } 

the issue i'm seeing right draw method never called means nothing appears in view.

i've tried lots , lots of permutations of constructors can see in control code. using cgrect.empty , in code manually generated cgrect no matter try cannot seem flow of code work.

as can see code if swap out custom control simple uibutton works expected main view code uiscrollview added constraints working , laying out expected , desired. problem seem lie either in control code or hierarchy of constraints themselves. cannot figure out needs happen make work.

under circumstances seeing following error:

unable simultaneously satisfy constraints. 

i've used "pattern" of code many times in other views within app , works in situations why i'm confused going on in situation. difference looping on dynamic number of controls in situation.

without changing current structure of view (to using uitableview instead) how can playing nicely , render custom uiview controls?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -