UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

TableView error in SwiftUI project

Forums > SwiftUI

Got a strange message when running Simulator for my SwiftUI app project. Using TabView as my main ContentView. Within that I have one index as my ProfileView with smiple Form, Sections and TextFields.

struct ProfileView: View {

    @State var firstName: String = ""
    @State var lastName: String = ""
    @State var department: String = ""

    var body: some View {
        VStack {
            TitleLabel(text: "User Profile")

            Form {
                Section(header: Text("Name").font(.body))  {
                    TextField("First name:", text: $firstName)
                    TextField("Last name:", text: $lastName)
                }
                Section(header: Text("Department"))  {
                    TextField("Department:", text: $department)
                }
                Section(header: Text("Photo")) {
                    Text("Picture will go here")
                }
            }
        }
    }
}

Note: TitleLabel is just a custom view with a font style alteration that will be used across all views in the app.

When I navigate into any view that has a Form inside of it, then navigate out of the view (back to home or any other), the debugger shows this error.

[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). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information 

Any ideas? Nothing rocket-sciencey here...

2      

SwiftUI is using the UIKit UITableView behind the scenes for List. When you added new entry to the list it automatically refreshed but because the screen was hidden you got this error.

2      

Thx for the reply, but seems odd as the Form is just part of the content view to display within a VStack. It's not poping up over the view, it is (as I understand it) a part of the view. So is this an error that I just need to ignore, or am I not handling something correctly? I try to code w/ zero errors, but maybe this is something out-side dev control?

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.