I was playing around with TableColumn api in MacOS Ventura I have the following data model.
actor HousingData: Identifiable {
let id: Int
let rank: Int
let region: String
let regionType: RegionType
let state: String
}
However when it try to do
TableColumn("foo", value: \.rank)
I get
Key path value type 'Int' cannot be converted to contextual type 'String'
if I try
TableColumn("Rank", value: \.rank) { rank in
Text("\(rank)")
}
I get
Referencing initializer 'init(_:value:content:)' on 'TableColumn' requires the types 'Never' and 'KeyPathComparator<HousingData>' be equivalent
If i use a string value all works well.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am noticing that adjustsImageWhenAncestorFocused causes the image to blur. Is there any way to get this not to happen? I am using vector images. I am trying to create a round button.
There seems to be no way to add dynamically add table columns to SwfitUI table. I have a column of dates that I store in an array like so.
let dates = [Date]
let values = [Int]
I want one able enumerate over the dates to generate columns. However I can't seem to find a way to enumerate over them and generate my columns. My current data set has 250 columns and it will keep growing.
I would love to do
ForEach(0 ..< dates.length) { index in
TableColumn("<some formatted date>") {
Text("\(value)")
}
}
But it appears that since TableColumn is not a view ForEach can't be used. Is there a supported way to build columns dynamically? This is a Mac application.
Does charts support a for each type symantic too?
If I past the samele code
import RegexBuilder
let fieldSeparator = /\s{2,}|\t/
let transactionMatcher = Regex {
/CREDIT|DEBIT/
fieldSeparator
One(.date(.numeric, locale: Locale(identifier: "en_US"), timeZone: .gmt))
fieldSeparator
OneOrMore {
NegativeLookahead { fieldSeparator }
CharacterClass.any
}
fieldSeparator
One(.localizedCurrency(code: "USD").locale(Locale(identifier: "en_US")))
}
It does not like the OneOrMore with the negative look ahead. Is there an updated example of this code from WWDC?
I have a scroll view with one item in it. When is scroll it under a the navigation bar it disappears before the whole cell is gone it seems to be about when ½ the cell is disappeared. Simple LazyVStack
NavigationView {
ZStack {
ScrollView {
LazyVStack {
ForEach(model.wallets, id: \.id) { wallet in
GalleryCell(wallet: wallet)
}
}
}
}
I have a really simple app where I am trying to scroll full page between images. However the if I use a LazyHStack the scrolling stops working if a child item is full screen. LazyVStack has the same issue if the content is full screen then scrolling stops working. Normal stacks work but that defeats the purpose since all items have to load. Oh this need to scroll horizontally.
Code is so:
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
ScrollView(.horizontal) {
LazyHStack {
ForEach(1...50, id: \.self) { index in
Button(action: {}){ Text("\(index)")}
.frame(width: geometry.size.width, height: geometry.size.height)
}
}
}
}
.ignoresSafeArea()
}
}
I have a SwiftUI application with a SignInWithAppleButton. However when I press the button with the remote I don't get any callbacks in the blocks. There is no error in the console that I can find.
Should the button work on tvOS 14?
The code is simple:
import SwiftUI
import AuthenticationServices
struct SignInView: View {
var body: some View {
VStack(spacing: 40) {
Text("Welcome to My App")
.font(.system(size: 50.0, weight: .bold))
SignInWithAppleButton(.signIn) { request in
request.requestedScopes = [.fullName, .email]
} onCompletion: { result in
print(result)
}
.signInWithAppleButtonStyle(.whiteOutline)
.frame(width: 300, height: 50)
}
}
}