locked
Why is ContentView null when using MvvmCross MvxTableCellView? RRS feed

  • Question

  • User2269 posted

    I'm trying to use MvvmCross with XibFree for a table within an iOS application. I'm following the XibFree walkthrough for tables here:

    http://www.toptensoftware.com/xibfree/uitableviewcell_fixed

    and the MvvmCross N=6.5 walkthrough here:

    https://github.com/slodge/NPlus1DaysOfMvvmCross/tree/master/N-06-Books/Books.Touch/Views

    The XibFree walkthrough calls for the layout to be added to the ContentView of the UITableViewCell in the constructor:

    this.ContentView.Add(new UILayoutHost(layout, base.ContentView.Frame));

    This works fine when my table cell inherits directly from UITableViewCell; however, if I inherit from MvxTableViewCell then ContentView is always null in the constructor. Looking through the source of MvvmCross I see that MvxTableViewCell inherits directly from UITableViewCell, doesn't appear to contain any code that modifies the ContentView, and calls the same UITableViewCell constructor that I call when inheriting directly from UITableViewCell (which works as expected).

    Has anyone else seen this? Is there a workaround or will I need to go with a pure XibFree implementation for my iOS table?

    Thanks in advance! Ryan

    Friday, July 19, 2013 3:10 AM

All replies

  • User3585 posted

    Just hitting the same trouble as you...

    For me, it seems to happen when you use the iOS6 reuse pattern with the MyCell(IntPtr p):base(p) ctor. The only workaround I've found is like @StuartLodge did in its tutorials (based on vNext for me): use a method Initialize() and invoke it just after the DequeueReusableCell call in my table source.

    I'm not really sure it is related to Mvvmcross or MonoTouch, but looks like more on iOS side for me...

    Monday, July 22, 2013 6:21 PM
  • User2269 posted

    That's the path I choose as well; however, I'm still having an issue with getting the MvxImageViewLoader to load images for each table cell. Typically 2 or 3 out of 30 load...and it's always completely random.

    Tuesday, July 23, 2013 2:54 AM
  • User2269 posted

    Nevermind, I switched to plain MvxImageView and set the AutoSize to FillParent and all is fine now.

    Tuesday, July 23, 2013 3:36 AM
  • User2029 posted

    I found a real fix ! It is a bug in MVVMCROSS !

    In MvxTableViewCell, if you remove the Accessory override, it works fine !

        //public override sealed UITableViewCellAccessory Accessory
        //{
        //    get { return base.Accessory; }
        //    set { base.Accessory = value; }
        //}
    
    Friday, December 20, 2013 11:32 AM