Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

ASTableView warning (view does not load) #241

Description

@trevorwelshh

Describe the bug
On first load the tableview works as expected, when switching to another view and going back the view is empty and this is the warning I get: "[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window)."

To Reproduce

@EnvironmentObject var hvm: HomeViewModel
ZStack(alignment: .top) {
                if self.hvm.moments.isEmpty && !self.isPreparingView {
                    VStack(alignment: .center, spacing: self.viewPadding) {
                        Text("Nothing to see here!")
                            .font(Font.pjsBold(size: 17))
                        Text("Check back later to see your Story Moments.")
                            .font(Font.pjsMedium(size: 16))
                    }
                    .foregroundColor(Color.theme.textLight)
                    .frame(width: geoSize.width, height: geoSize.height)
                } else if !self.isPreparingView {
                    ASTableView(section: ASTableViewSection(id: 0, data: self.hvm.moments, contentBuilder: { moment, cell in
                        MediaView(showSaveAnimation: self.$showSaveAnimation, currentUserData: self.$currentUserData, moments: self.$hvm.moments, moment: moment, geo: geo, viewPadding: self.viewPadding)
                    }))
                    .onScrollDidEnd({ scrollView, velocity in
                        if velocity.y > 1.5 && self.hvm.momentIndex != (self.hvm.moments.count - 1) {
                            self.hvm.momentIndex += 1
                            self.scrollPosition = .pageDown(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                        } else if velocity.y < -1.5 && self.hvm.momentIndex != 0 {
                            self.hvm.momentIndex -= 1
                            self.scrollPosition = .pageUp(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                        } else {
                            self.scrollPosition = .pageZero(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                        }
                    })
                    .scrollPositionSetter(self.$scrollPosition)
                    .scrollIndicatorEnabled(false)
                    .separatorsEnabled(false)
                    
                    CustomNotifView(showNotifAnimation: self.$showSaveAnimation, imageSystemName: "checkmark", text: "Saved to your moments", notifTimeShown: 1.0, geoSize: geoSize)
                        .frame(width: geoSize.width, height: geoSize.height, alignment: .center)
                }
            }
            .ignoresSafeArea(.all, edges: .top)
            .onAppear {
                print(self.hvm.moments)
                guard self.hvm.moments.isEmpty else {
                    self.scrollPosition = .pageZero(CGPoint(x: 0, y: CGFloat(self.hvm.momentIndex) * geoSize.height))
                    return
                }
                if let userLiveStory = self.userLiveStory {
                    self.hvm.getNewLiveMedias(userData: self.currentUserData, userLiveStory: userLiveStory) {
                        self.isPreparingView = false
                        self.scrollPosition = .top
                    }
                } else {
                    self.udm.getLiveUserStory(userID: self.currentUserData.id) { userLiveStory in
                        guard let userLiveStory = userLiveStory else { return }
                        self.userLiveStory = userLiveStory
                        self.hvm.getNewLiveMedias(userData: self.currentUserData, userLiveStory: userLiveStory) {
                            self.isPreparingView = false
                            self.scrollPosition = .top
                        }
                    }
                }
            }

Expected behaviour
I expect the view to show the original view after switching back since the data is store in an environmentobject. (cacheCells() does not work)

Xcode Version:

  • 13.3

Simulator, Device, Both?

  • device

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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