Theodor Ungureanu
Theodor Ungureanu

Reputation: 293

SwiftUI Tabview - Missing argument for parameter 'tab' in call

I am trying to play around with the new TabView from swift but I keep receiving this error:

"Missing argument for parameter 'tab' in call".

Can you help me figure out the source of this error?

Here is the code:

import SwiftUI

struct View1: View {
    var body: some View {
        ScrollView {
            HStack {
                PageView()
            }
        }
    }
}

struct PageView: View {
    var body: some View {
        if #available(iOS 14.0, *) {
            TabView {
                ForEach(0..<30) { i in
                    ZStack {
                        Color.black
                        Text("Row: \(i)").foregroundColor(.white)
                    }.clipShape(RoundedRectangle(cornerRadius: 10.0, style: .continuous))
                }
                .padding(.all, 10)
            }
            .frame(width: UIScreen.main.bounds.width, height: 200)
            .tabViewStyle(PageTabViewStyle())
        } else {
            // Fallback on earlier versions
            Text("something")
        }
    }
}

Here is a picture of error:

enter image description here

Upvotes: 1

Views: 356

Answers (1)

pawello2222
pawello2222

Reputation: 54486

It looks like the TabView is a custom component (judging by Xcode syntax highlighting).

Try using SwiftUI explicitly:

SwiftUI.TabView {
    // ...
}

Upvotes: 1

Related Questions