AsyncImage in List is broken on iOS 16

354 views Asked by At
struct Item: Identifiable {
    let id: String
    let url = URL(string: "https://styles.redditmedia.com/t5_j6lc8/styles/communityIcon_9uopq0bazux01.jpg")!
}

struct Content: View {

    let model: [Item] = {
        var model = [Item]()
        for i in 0 ..< 100 {
            model.append(.init(id: String(i)))
        }
        return model
    }()

    var body: some View {
        List(model) { item in
            Row(item: item)
        }
    }

}

struct Row: View {

    let item: Item

    var body: some View {
        AsyncImage(url: item.url)
    }

}

Running code above with Xcode 14.1 on iOS 16.1 simulator, AsyncImage sometimes doesn’t properly show downloaded image but grey rectangle instead when scrolling in list. Is this bug or am I missing something? Thanks

2

There are 2 answers

0
Oliver Findra On

My solution was to use VStack in ScrollView instead of List. It looks like it's working and it doesn't have any other drawbacks.

0
SEO plus Marketing On

.fixedSize() fixed the problem me