Post

Replies

Boosts

Views

Activity

Reply to VStack within ScrollView on macOS 15.2 makes bottom area unclickable
I tested in Xcode 16.2 with iOS 18.1 simulator, MacOS 14.7. It works with horizontal and VStack (even though buttons are squeezed in the lower left corner). I doubt the problem may come from macOS version. Same in Xcode 15.3 with iOS 18.1 simulator. Same with Xcode 15.0.1 and simulator 18.0. Could you test the modified code to see if it works on real device (and simulator): struct ContentView: View { @State private var showFoo = false @State private var showBar = false var body: some View { ScrollView(.horizontal) { VStack { Spacer() // this button is clickable Button("foo") { print("foo") showFoo.toggle() } // this button can't be clicked Button("bar") { print("bar") showBar.toggle() } if showFoo { Text("Foo")} if showBar { Text("Bar")} } } } }
26m
Reply to I don’t think the math is mathing. How is this possible?
This is a question about an existing app (you don't tell which unfortunately), not for an app development. So this forum is not the right place to post the question.   is there a way to fix this? You should ask on the app's developer forum. For some reason, the app has registered a total screen time of 139h05'. But only a small part falling in one of the categories. Hence, an average oh 19h52' per day (math is exact). It is up to you to understand how total screen time is accounted depending on the settings you may have defined.
4h
Reply to Updating EditButton
This thread may provide some hints: https://www.hackingwithswift.com/forums/swiftui/list-view-stuck-in-edit-mode/7401 It tested this, which apparently does what you need: struct ContentView: View { @State private var selects: Set<Int> = [] @State var range = [1, 2, 3 ,4, 5] @Environment(\.editMode) var editMode var body: some View { VStack{ EditButton() List(selection: $selects){ ForEach(range, id: \.self) { ItemInList(num: $0) } .onDelete { range.remove(atOffsets: $0) editMode?.wrappedValue = .inactive } } .listStyle(PlainListStyle()) } } }
1d
Reply to On a brand new build, why would I get this error: "Error creating the CFMessagePort needed to communicate with PPT."
I get the same message in log when creating a project in Xcode 16.2 on MacMini with MacOS 14.7.2. Error creating the CFMessagePort needed to communicate with PPT. Failed to send CA Event for app launch measurements for ca_event_type: 0 event_name: com.apple.app_launch_measurement.FirstFramePresentationMetric Failed to send CA Event for app launch measurements for ca_event_type: 1 event_name: com.apple.app_launch_measurement.ExtendedLaunchMetrics I tested on Xcode 15.3 creating a new project does not show the log but another one: Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables. opening the project created with 16.2 crashed Xcode, even after changing project format to Xcode 15.3 from 16.0. As the Xcode 16,2 project works without problem, that seems to be just log noise. You could file a bug report however.
1d
Reply to textfield does not allow any user input
Why do you need to create a new UITextField in the IBAction ? You recreate a new UITextField which hides the existing one, hence you cannot enter anything). The logical way to do it: create the UITextField in the storyboard (I understand you did it) connect to an IBOutlet that you name nameTextField declare the placeholder in the storyboard (attributes inspector). It will be displayed automatically when the textField is empty. do not create the IBAction yet Then you should be able to type in nameTextField If you need an IBAction (but do NOT create nameTextField subview inside) declare in storyboard that the delegate of the textField is the UIViewController declare that the UIViewController conforms to UITextFieldDelegate change the IBAction (if you need to have some action once text entered) by: @IBAction func insertName(_ sender: UITextField) { let enteredName = sender.text print("Entered Name:", enteredName ?? "") } What is the error message on line 13 ?
2d
Reply to Stuck using variable in the tex statement
If I am honest this bit of code was generated, after a lot of trial and error by ChatBT. That's a problem when you don't understand the code you use. Did you ask CGT to solve the issue, as they proposed the code ? 😉 Returning to human answer, you didn't answer my question. Did you test the code I sent you? What is the result ?
2d
Reply to Stuck using variable in the tex statement
Could you test: case rule.hasSuffix("wins."): // "Player to reach X wins." let topScorers = scores.filter { $0.1 >= target } if !topScorers.isEmpty { print("topScorers not Empty") // <<-- ADD THIS let maxScore = scores.max(by: { $0.1 < $1.1 })?.1 ?? 0 let topScorers2 = scores.filter { $0.1 == maxScore } // <<-- CHANGE to topScorers2 gameIsDraw = topScorers2.count > 1 winner = topScorers2.count == 1 ? topScorers2.first?.0 : nil And tell what you get. A comment. Even if the syntax is correct, let maxScore = scores.max(by: { $0.1 < $1.1 })?.1 ?? 0 is hard to read. .1 is a property, it would be so easier to read by using the property name
2d
Reply to UIViewRepresentable is not working
I tested this part of code, with no error, as long as you include the updateUIView function, even empty. struct WebViewContainerRepresentable: UIViewRepresentable { typealias UIViewType = WKWebView func makeUIView(context: Context) -> WKWebView { let webView = WKWebView() if let url = Bundle.main.url(forResource: "index", withExtension: "html") { webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent()) } return webView } func updateUIView(_ uiView: WKWebView, context: Context) { // Updates not required for this use case } }
3d
Reply to array
So, you will pass the array populated with the prices (in fact, you probably need to pass more information, to know to which pizza or customer a price refers to). Is it for SwiftUI or UIKit ? for SwiftUI, you would have a State var with the costs (or more info) and could use List to display @State var costs: [Double] = [] // You will have to append this array when you add a pizza In the body of the View, something like: struct ContentView: View { @State var costs: [Double] = [] // You will have to append this array when you add a pizza @State var newCost: Double = 0 var body: some View { VStack { List(costs, id: \.self) { cost in Text("cost: \(String(format: "%4.2f", cost) )") } HStack { Text("New pizza cost") TextField("", value: $newCost, format: .number) .border(.blue) } Button(action: { if newCost > 0 { self.costs.append(newCost) } newCost = 0 }) { Text("Append") } Spacer() } } }
3d
Reply to array
I'm not sure to understand. With the present code: func myfunc(costa: [Double]) { } myfunc(costa:[ ]) calling with [] parameter of course uses an empty array. If you call func myfunc(costa: [Double]) { print(costa.count) } myfunc(costa:[ 10.0, 20.0]) It will not be empty. You will see in log it has 2 items. But is it what you want ? What do you do in myfunc ? Just use the array (as in the example above) ? Or add items to the array ?
3d