Post not yet marked as solved
That's new functionality to me, but I cannot appear to get it to work.
The best I can get is adding a redacted view in the 'second' secondary view. Otherwise the List is generating the second secondary view.
Post not yet marked as solved
I was able to get this working with the latest iOS 14 beta. It appears .buttonStyle(PlainButtonStyle()) stops the List Row itself being selected and .foregroundColor(Color.accentColor) to get the button accent colour back.
import SwiftUI
struct ContentView: View {
@State var inputString = ["1", "2", "3", "4", "5"]
init() {
// Didn't appear to need this thank goodness!
//
// UITableView.appearance().allowsSelection = false
// UITableViewCell.appearance().selectionStyle = .none
}
var body: some View {
Text("List Item with selectable Buttons").padding()
List {
ForEach(0..<5) { idx in
HStack {
Text("Title")
TextField("Enter new value",text: $inputString[idx])
Spacer()
Button(action: {
print("Button did select 1 at idx \(idx)")
}) {
Text("Selectable 1")
}.buttonStyle(PlainButtonStyle())
.foregroundColor(Color.accentColor)
Button(action: {
print("Button did select 2 at idx \(idx)")
}) {
Text("Selectable 2")
}.buttonStyle(PlainButtonStyle())
.foregroundColor(Color.accentColor)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}