Why is ContentView null when using MvvmCross MvxTableCellView?

rjygrahamrjygraham USBeta ✭✭

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

Answers

  • GuillaumeGirardGuillaumeGirard CAMember ✭✭

    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...

  • rjygrahamrjygraham USBeta ✭✭
    edited July 2013

    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.

  • rjygrahamrjygraham USBeta ✭✭

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

  • softlionsoftlion FRBeta ✭✭✭

    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; }
        //}
    
Sign In or Register to comment.