swiftui-list

SwiftUI List not getting updated when `listRowInsets` are applied

大憨熊 提交于 2020-12-13 04:32:01
问题 Goal Update data in a List on tap Problem When .listRowInsets are applied to the list rows, the list stops getting updates when the state changes. Code struct ContentView: View { private var array = ["a", "b", "c"] @State private var selectedIndex = 0 var body: some View { makeBody() } private func makeRow(_ t: String, index: Int) -> some View { return HStack { Text(t) Spacer() if selectedIndex == index { Image(systemName: "checkmark.circle") } } .contentShape(Rectangle()) .onTapGesture {

Why do some views appear as a red no entry sign in widgets?

你说的曾经没有我的故事 提交于 2020-12-04 15:58:04
问题 I've created a project in xcode 12 and added a Widget Extension target. The target is created and I'm left with a simple widget that shows the time. The preview of the widget works as expected and the widget is shown as expected in the simulator. But if I change the view to use List instead of Text , like this: struct SimpleWidgetEntryView : View { var entry: Provider.Entry var body: some View { List { Text("Something") } } } The preview and the simulator both show a red No Entry sign on a

SwiftUI - nested list

╄→гoц情女王★ 提交于 2020-11-29 08:17:30
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual

SwiftUI - nested list

社会主义新天地 提交于 2020-11-29 08:14:45
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual

SwiftUI - nested list

偶尔善良 提交于 2020-11-29 08:14:32
问题 I'm trying to create a nested hierarchical list, so that for each task I can have subtasks like in iOS reminders app: First attempt was to embed another list inside a list cell. import SwiftUI struct SwiftUIView: View { var body: some View { List { List { Text("Hello, World!") } } } } struct SwiftUIView_Previews: PreviewProvider { static var previews: some View { SwiftUIView() } But, didn't work out... Anyone can help? cheers 回答1: Why do you think it should be List in List... Such visual