Post

Replies

Boosts

Views

Activity

Reply to My app Xcode SwiftUI
You have probably a free developer license ? If so, you have to rebuild app regularly (I thought it was every week, but may be shorter). The point is that free licence is done to let you learn to develop, not really to build apps to use.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to SwiftUI chart legend overflow
I tried with Xcode 16.0ß and Xcode 15.3, on iOS 17.4 and 18.0 simulators and got a correct result. It is not wrapped but correctly positioned and sized. So I extended your text further more and got a correct result again: And even more, to exceed width limit: ChartData(id: 2, title: "Item 2 With a Long Title and then some more and even some more for a crazy legend length", count: 6, color: .blue), Then it did not work. I used a different modifier to build the legend manually: .chartLegend(alignment: .leading, content: { HStack(alignment: .top, spacing: 5) { ForEach(data) { d in HStack { Text("•") .font(.system(size: 48)) .bold() .foregroundStyle(d.color) Text("\(d.title)") .font(.system(size: 14)) .lineLimit(nil) // Multilines .foregroundStyle(Color.gray) } .frame(width: 125, height: 120) } } }) You can adapt content to better fit your need.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to Data update issue when both parent and child views are @State in SwiftUI
For the first question. You have to use Binding and not State in SubView1: struct SubView1: View { // @State var data: String @Binding var data: String And of course call it appropriately: SubView1(data: $data) With State, you keep the state of the var. With Binding, you reference the parameter passed, so it is updated. In SubView2, you pass directly the parameter, so it is used for display. For your second question, my understanding is that effectively the compiler optimises the views creation. As Subview1 is already created, it can reuse it immediately without creating a new instance.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to I want to limit input on textfield...
You shoals use the onChange on TextField to test on the fly. Do it in onSubmit to test only when you hit return key. If the State var in the TextField is input, you should test if only letters .onChange(of: input) { oldInput, proposedInput in if onlyLetters(proposedInput) { input = proposedInput } else { input = oldInput } } onlyLetters is a func to test the proposed string contains only letters. func onlyLetters(_ s: String) -> Bool { return resultoftest } See here a way to implement: https://stackoverflow.com/questions/60657152/how-to-check-whether-string-only-consists-of-letters-and-spaces-in-swift-5
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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
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 How to disable screen record/capture?
No, there is no API for this. And, as you can find in many posts on the forum which asked this question, there is no sure way to achieve it. It would always be possible to shoot a photo of the screen from a second device.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Membership expired, no where to renew it?
Could you show the screen you get after you signed in ? If not successful, I advise you to contact support. They will tell where the problem is.
Replies
Boosts
Views
Activity
Jun ’24
Reply to My app Xcode SwiftUI
You have probably a free developer license ? If so, you have to rebuild app regularly (I thought it was every week, but may be shorter). The point is that free licence is done to let you learn to develop, not really to build apps to use.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Can I enroll my iPhone 6s?
iPhone 6s is limited to iOS 15. So you cannot install betas of iOS 18 for instance.
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftUI chart legend overflow
I tried with Xcode 16.0ß and Xcode 15.3, on iOS 17.4 and 18.0 simulators and got a correct result. It is not wrapped but correctly positioned and sized. So I extended your text further more and got a correct result again: And even more, to exceed width limit: ChartData(id: 2, title: "Item 2 With a Long Title and then some more and even some more for a crazy legend length", count: 6, color: .blue), Then it did not work. I used a different modifier to build the legend manually: .chartLegend(alignment: .leading, content: { HStack(alignment: .top, spacing: 5) { ForEach(data) { d in HStack { Text("•") .font(.system(size: 48)) .bold() .foregroundStyle(d.color) Text("\(d.title)") .font(.system(size: 14)) .lineLimit(nil) // Multilines .foregroundStyle(Color.gray) } .frame(width: 125, height: 120) } } }) You can adapt content to better fit your need.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to xcodebuild destination for any mac
Maybe you'll find the answer here: https://mokacoding.com/blog/xcodebuild-destination-options/ Source : https://forums.developer.apple.com/forums/thread/702296
Replies
Boosts
Views
Activity
Jun ’24
Reply to Data update issue when both parent and child views are @State in SwiftUI
For the first question. You have to use Binding and not State in SubView1: struct SubView1: View { // @State var data: String @Binding var data: String And of course call it appropriately: SubView1(data: $data) With State, you keep the state of the var. With Binding, you reference the parameter passed, so it is updated. In SubView2, you pass directly the parameter, so it is used for display. For your second question, my understanding is that effectively the compiler optimises the views creation. As Subview1 is already created, it can reuse it immediately without creating a new instance.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to I want to limit input on textfield...
You shoals use the onChange on TextField to test on the fly. Do it in onSubmit to test only when you hit return key. If the State var in the TextField is input, you should test if only letters .onChange(of: input) { oldInput, proposedInput in if onlyLetters(proposedInput) { input = proposedInput } else { input = oldInput } } onlyLetters is a func to test the proposed string contains only letters. func onlyLetters(_ s: String) -> Bool { return resultoftest } See here a way to implement: https://stackoverflow.com/questions/60657152/how-to-check-whether-string-only-consists-of-letters-and-spaces-in-swift-5
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
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