Post

Replies

Boosts

Views

Activity

Reply to TextField("x", value: $y, format: .currency(code: "USD")) Behaves oddly
I would do it with a text format: struct ContentView: View { @State private var usdAmount = 0.0 @State private var usd = "0" var body: some View { VStack { Text("Currency Form") Form { // TextField("Dollar Amount", value: $usdAmount, format: .currency(code: "USD")) // 1 TextField("Dollar Amount", value: $usdAmount, format: .number) // 2 .keyboardType(.numberPad) TextField("Dollar Amount", text: $usd) // text format .keyboardType(.numberPad) .onTapGesture { usd = "" } .onSubmit { usdAmount = Double(usd) ?? 0.0 usd = "$ " + usd } } Text("usdAmount = \(usdAmount) \(usd)") } .padding() } }
Topic: UI Frameworks SubTopic: SwiftUI
Jun ’24
Reply to SwiftUI app runs differently on hardware platforms
I tested on MacMini, MacOS 14.5, Xcode 15.3. For what it's worth. Do you get this error in log: Picker: the selection "0" is invalid and does not have an associated tag, this will give undefined results. Replacing @State var psel:Int = 0 by @State var psel:Int = 1 clears the error I also get this error when selecting in Picker: CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to Can't typing on NSTextField
So the test shows that showSuggestionMenu removes focus. I didn't say that was the solution, just a way of testing. So now, as I suggested before, try to reset focus after updateSuggestionMenu() showSuggestionMenu()
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’24
Reply to Moving focus between textfields using enter key
Use FocusState. Here is a simple code example: struct ContentView: View { let textCase1 = 1 let textCase2 = 2 @State var text1: String = "" @State var text2: String = "" @FocusState private var focusedField: Int? var body: some View { VStack { HStack { Text(" TextField 1") TextField("", text: $text1) .border(Color.blue, width: 1) .focused($focusedField, equals: textCase1) .onSubmit { focusedField = 2 } } HStack { Text(" TextField 2") TextField("", text: $text2) .border(Color.red, width: 1) .focused($focusedField, equals: textCase2) .onSubmit { focusedField = 1 } } Button { focusedField = nil print("No more focus") } label: { Text("Do something else") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to Closure | Error when referring static variable
You can refer to a static variable. As shown in the small code below: struct Preview: View { private static let NAME = "Test" var array: [String] = ["someTest", "Hello", "HelloTest"] var filtered: [String] { array.filter { $0.contains(Preview.NAME) } } var body: some View { ForEach(filtered, id: \.self) { s in Text(s) } } } So the problem is the use in the Query. May be you could try to include in a computed var ?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Reply to How to close DatePicker after selection in View?
The picker is in a View, but isn't this View in a ViewController ?
Topic: UI Frameworks SubTopic: UIKit
Replies
Boosts
Views
Activity
Jun ’24
Reply to Apple: please unlock "enterprise features" for all visionOS devs!
You should post a Feedback with your suggestions.
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Xcode 15.4 from the App Store will not open on MacOS 14.5
I so often had problem downloading from appStore (may be the servers are too busy ?) that I now always download directly. In addition that's easier to keep several versions of Xcode, notably betas (no need to trash the existing Xcode, just give different names as Xcode 15.4). Wish you good continuation.
Replies
Boosts
Views
Activity
Jun ’24
Reply to Xcode 15.4 from the App Store will not open on MacOS 14.5
Try to load from here https://xcodereleases.com and please report what you get.
Replies
Boosts
Views
Activity
Jun ’24
Reply to TextField("x", value: $y, format: .currency(code: "USD")) Behaves oddly
I would do it with a text format: struct ContentView: View { @State private var usdAmount = 0.0 @State private var usd = "0" var body: some View { VStack { Text("Currency Form") Form { // TextField("Dollar Amount", value: $usdAmount, format: .currency(code: "USD")) // 1 TextField("Dollar Amount", value: $usdAmount, format: .number) // 2 .keyboardType(.numberPad) TextField("Dollar Amount", text: $usd) // text format .keyboardType(.numberPad) .onTapGesture { usd = "" } .onSubmit { usdAmount = Double(usd) ?? 0.0 usd = "$ " + usd } } Text("usdAmount = \(usdAmount) \(usd)") } .padding() } }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftUI app runs differently on hardware platforms
I tested on MacMini, MacOS 14.5, Xcode 15.3. For what it's worth. Do you get this error in log: Picker: the selection "0" is invalid and does not have an associated tag, this will give undefined results. Replacing @State var psel:Int = 0 by @State var psel:Int = 1 clears the error I also get this error when selecting in Picker: CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Problem with new UITabbarController on IOS 18 beta (Bug?)
Likely, the content is reloaded from storyboard. Did it work OK in iPadOS 17 ? where do you set set theTabBarController.tabBar.items[0].title Did you try to set theTabBarController.tabBar.items[0].title for instance in override func viewWillLayoutSubviews() {
Topic: UI Frameworks SubTopic: UIKit
Replies
Boosts
Views
Activity
Jun ’24
Reply to Previewing your app’s interface in Xcode
Which version of Xcode do you use ? #Preview is available only in Xcode 15 and over. If you use an older version, replace #Preview { // The view to preview. } by: struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Replies
Boosts
Views
Activity
Jun ’24
Reply to iPhone 13 no longer connecting to LTE or 5G
17.5.1 is now released. Did you try installing ? But your question would better be posted on Apple support community: https://discussions.apple.com/welcome
Replies
Boosts
Views
Activity
Jun ’24
Reply to Screen tome big on ios 18 beta
That's not a question for developers forum. You'd better post on Apple Support Community: https://discussions.apple.com/welcome
Replies
Boosts
Views
Activity
Jun ’24
Reply to Can't typing on NSTextField
So the test shows that showSuggestionMenu removes focus. I didn't say that was the solution, just a way of testing. So now, as I suggested before, try to reset focus after updateSuggestionMenu() showSuggestionMenu()
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Moving focus between textfields using enter key
Use FocusState. Here is a simple code example: struct ContentView: View { let textCase1 = 1 let textCase2 = 2 @State var text1: String = "" @State var text2: String = "" @FocusState private var focusedField: Int? var body: some View { VStack { HStack { Text(" TextField 1") TextField("", text: $text1) .border(Color.blue, width: 1) .focused($focusedField, equals: textCase1) .onSubmit { focusedField = 2 } } HStack { Text(" TextField 2") TextField("", text: $text2) .border(Color.red, width: 1) .focused($focusedField, equals: textCase2) .onSubmit { focusedField = 1 } } Button { focusedField = nil print("No more focus") } label: { Text("Do something else") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to AI
Depends what you mean. But a lot of advanced functions that require intensive on board processing will only be available on 15 Pro and above…
Replies
Boosts
Views
Activity
Jun ’24
Reply to Closure | Error when referring static variable
You can refer to a static variable. As shown in the small code below: struct Preview: View { private static let NAME = "Test" var array: [String] = ["someTest", "Hello", "HelloTest"] var filtered: [String] { array.filter { $0.contains(Preview.NAME) } } var body: some View { ForEach(filtered, id: \.self) { s in Text(s) } } } So the problem is the use in the Query. May be you could try to include in a computed var ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to problem with charger other than Apple
Is the charger MFI certified ? Anyway, this is not a question for this forum. You'd better ask on Apple Support Community https://discussions.apple.com/welcome
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’24