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()
}
}
Post
Replies
Boosts
Views
Activity
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.
Yup. I've filed lots.
Yesterday I wiped the Studio clean and reinstalled a fresh build of Monterey. Reinstalled the same software and copied the latest account from the MacBook Pro. I'm still seeing the slow objective c compiles!
Further investigation, checked Compiler settings to other projects I have in Objective-C they look similar and the differences do not look as if they would matter. These other Obj-C projects compile as fast on the Ultra and the time taken in the same ballpark.
The only thing I see which is a big difference with these slow Obj-C files is the totally crazy size of -I includes in the compile statement. As far as I understand it, a lot of these -I includes are auto-generated from the various frameworks we need to include in our build via Carthage. Looking at a single file I can count 2825 -I statements!!!! But why would this affect an Ultra system more when compared to an M1 Pro machine? Perhaps I'm going down the wrong rabbit hole, but that is the only thing I am seeing different at the moment.