実現したいこと
配列のテキスト表示
前提
ContentViewのリストを表示したい
発生している問題・エラーメッセージ
Cannot convert value of type 'String' to expected argument type '() -> Label'
該当のソースコード
SwiftUI
12struct ContentView: View { 3var pinned = [""] 4var body: some View { 5NavigationView { 6List{Section(header: Text("テキスト")){ForEach(0..<pinned.count) { index in NavigationLink(destination: AnotherView, label: pinned[index])}} } 7}}} 8 9 10 11struct AnotherView: View { 12var body: some View { 13Text("テキスト") 14}} 15 16struct ContentView_Previews: PreviewProvider { 17 static var previews: some View { 18 ContentView() 19 } 20} 21

0 コメント