locked
Possible Bug(?) with DialogViewController and StyledMultilineElement RRS feed

  • Question

  • User64190 posted

    I am creating an app using DialogViewController. Each unique view of this app is handled by implementing a subclass to a DialogViewController which is constructed using "public ViewName() : base( UITableViewStyle.Plain, null, true) {...}".

    I procedurally build the Sections and Elements based on what is persisted in my database. If in the constructor, I build StyledMultilineElement that exceed the standard cell height these elements properly auto resize and provide the right amount of space for the elements. But if I build the same elements within an "override void ViewWillAppear(bool Animated)", this resizing doesn't work, and all the cells created use only the default size.

    Is this a bug? If not, how do I fix it?

    Thanks.

    Wednesday, July 23, 2014 5:51 PM

All replies

  • User64190 posted

    This appears to be a bug in the implementation of the Default Sizing source. If I implement this code in my DialogViewController:

    public override Source CreateSizingSource(bool unevenRows) {
        return new RevisedSizingSource( this );
    }
    

    And create this class:

    public class RevisedSizingSource : DialogViewController.Source {
    
        public RevisedSizingSource( DialogViewController controller ) : base( controller ) {
        }
    
        public override float GetHeightForRow(UITableView tableView,NSIndexPath indexPath) {
            // This next line is revised from the assembly browser view
            Section section = this.Root[indexPath.Section];        
    
            Element element = section.Elements[indexPath.Row];
            IElementSizing elementSizing = element as IElementSizing;
            if ( elementSizing == null ) {
                return tableView.RowHeight;
            }
            return elementSizing.GetHeight( tableView,indexPath );
        }
    }
    

    The problem goes away. The issue appears to be how the "section" variable gets initialized. The rest of the code is exactly how a SizingSource object is represented in the Assembly Browser.

    Thursday, July 24, 2014 5:21 PM
  • User64190 posted

    Reported this as bug: https://bugzilla.xamarin.com/show_bug.cgi?id=21586

    Thursday, July 24, 2014 9:56 PM