ASCollectionView icon indicating copy to clipboard operation
ASCollectionView copied to clipboard

ASCollectionView Incorrect Cell Sizing Before Scroll?

Open moxie0 opened this issue 6 years ago • 0 comments

Using a minimal code sample:

import SwiftUI
import ASCollectionView_SwiftUI

struct SampleViewModel : Identifiable {
    let id : Int
}

struct ContentView: View {
    
    @State var viewModels : [SampleViewModel] = []
    
    var body: some View {
        ASCollectionView(data: viewModels) {
            (viewModel : SampleViewModel, context: ASCellContext) in
            Text("\(viewModel.id)")
        }.onAppear {
            self.load()
        }
    }
    
    func load() {
        DispatchQueue.main.async {
            self.viewModels = (0 ..< 10).map { (i : Int) in
                    SampleViewModel(id: i)
            }
        }
    }
}

The first four cells are rendered correctly sized, but the subsequent three cells are rendered "too tall." Inspecting the layout reveals that the Text views are sized correctly, but the parent ASCollectionViewCell are mysteriously large.

Simulator Screen Shot - iPhone 11 Pro - 2020-09-07 at 17 39 05

The instant that you scroll the ASCollectionView, all cells are rendered correctly for the duration of the ASCollectionView's existence:

Simulator Screen Shot - iPhone 11 Pro - 2020-09-07 at 17 41 06

Xcode Version:

  • 11.7

Simulator, Device, Both?

  • Simulator and device, iOS 13.6.1 and iOS 13.7

moxie0 avatar Sep 08 '20 00:09 moxie0