前提
ListはNavigationLinkの中で使用しています。
var body: some View {
NavigationView {
List{Section(header: Text("テキスト")){ForEach(0..<self.pinned.count) {index in NavigationLink(destination: AnotherView, label: {Text(pinned[index])}}}}
}
}}
実現したいこと
List内のNavigationLinkでの別Viewへの遷移
発生している問題・エラーメッセージ
Type 'AnotherView.Type' cannot conform to 'View' Cannot convert value of type 'Binding<[String]>' to expected argument type 'Binding<String>'
該当のソースコード
SwiftUI
1 2struct ContentView: View { 3 4@State var pinned = [""] 5 6var body: some View { 7NavigationView { 8List{Section(header: Text("テキスト")){ForEach(0..<self.pinned.count) {index in NavigationLink(destination: AnotherView, label: {Text(pinned[index])}}}} 9} 10}} 11 12--- 13 14struct AnotherView: View { 15 16@State var textEditorText: [String] 17 18var body: some View { 19 20TextEditor(text: $textEditorText).frame(width: 200, height: 200) 21 22}.onAppear{textEditorText = [index]} 23 24} 25
試したこと
補足情報(FW/ツールのバージョンなど)
Xcodeはバージョン14.1です。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。