Skip to content

Cells disappearing from UICollectionView #14

@ajayghodadra

Description

@ajayghodadra

Hi,

I know this library does not support self-sizing cells.
To make it work with the dynamic width I am setting cell width based on the highest (longest) textLabel width based on sizeWithFont... method.

//Assuming max width = 200

func dataGridView(_ dataGridView: DataGridView, widthForColumn column: Int) -> CGFloat {
     return dataSource.columnWidths[dataSource.header[column].key] ?? 0
 }
func dataGridView(_ dataGridView: DataGridView, heightForRow row: Int) -> CGFloat { 
    return dataSource.rows[row].max(by: {$1.height > $0.height})?.height ?? 0
}

For calculating height I am using max textLabel height for that particular row and applying it to each component of that row.

This works perfectly fine in most of the cases but sometimes the cells start disappearing randomly. It shows up again when I scroll up/down a bit.

I tried various solutions posted on community(http://ioscake.com/uicollectionviews-cell-disappearing.html) and came to a conclusion that this can only happen if layoutAttributesForElements(in rect: CGRect) returns wrong attributes.

In most cases it seems to happen only when the rows are more than 100..

@glyuck It there cance that layoutAttributesForElements returns false attributes? I would really appreciate if you could help me with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions