Post

Replies

Boosts

Views

Activity

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 ?
Topic: UI Frameworks SubTopic: UIKit
Dec ’24
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 ?
Dec ’24
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
Dec ’24
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 } }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Stuck using variable in the tex statement
So that means winner is nil. There is likely an error here: gameIsDraw = topScorers.count > 1 winner = topScorers.count == 1 ? topScorers.first?.0 : nil gameIsDraw is true if count > 1 But winner is defined when count == 1 It should probably be winner = topScorers.count >= 1 ? topScorers.first?.0 : nil
Dec ’24
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() } } }
Dec ’24
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 ?
Dec ’24
Reply to Seeking advice on why Dog Translator Game for Dogs violates guideline 1.1.6 Safety: Objectionable Content
Including the "game" word and a notice that it is for entertainment only is not enough according to guideline 1.1.6 False information and features, including inaccurate device data or trick/joke functionality, such as fake location trackers. Stating that the app is “for entertainment purposes” won’t overcome this guideline. My understanding is that reviewer considers that some people will think they are able to speak to their dog. That's what your app name suggests with "Translator" and that could mislead users into thinking they will be able to "speak" dog. No one can give sure advice to pass review, but… At least, you could rename completely the app, eliminating the translator word. May be something like "Barking like a dog" or "Barking" ? would be more acceptable. And check that your app cannot be understood as a way to speak to a dog. Even the icon should take care of this, as well as all textes and images in the app. Good luck.
Dec ’24
Reply to Building Issue
Welcome to the forum. Is it a project (not a playground) ? Do you mean this right pointing black triangle on the right? Which version of Xcode ? Do you see a simulator selected in the top line ? What happens if you create a new project (iOS project, SwiftUI for instance) ? Do you get the triangle ? If not, you may have to reinstall Xcode
Topic: App & System Services SubTopic: General Tags:
Dec ’24
Reply to How to animate substring in a Text?
What do you want ? conversation/ meeting/ lecture to have always the same size ? Have the whole string with the same size ? For the later I tried using scaleEffect, which seems to be giving the expected result. struct ContentView: View { var array = ["lecture", "conversation", "meeting"] var scaleEffects = [1.0, 0.9, 1.0] // <<-- ADDED : firstString forces scale down @State var currentIndex : Int = 0 @State var firstString : String = "" @State var scale = 1.0 // <<-- ADDED var body: some View { VStack { HStack { Text("Transform") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) Text(firstString) .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) .transition(AnyTransition.opacity.animation(.easeInOut(duration:1.0))) .background(.yellow) Text("to Quick Note") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) } .padding() .frame(width: 420) .scaleEffect(x: scale, y: scale) // <<-- ADDED } .animation(.default) .onAppear { firstString = array[0] scale = scaleEffects[0] // <<-- ADDED let timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in if currentIndex == array.count - 1 { self.firstString = array[0] self.scale = scaleEffects[0] // <<-- ADDED currentIndex = 0 } else { self.firstString = array[currentIndex+1] self.scale = scaleEffects[currentIndex+1] // <<-- ADDED currentIndex += 1 } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to iOS 18.3 bata 1?
OK, you think you can manage iOS release planning ? You'll have to wait until Apple decides it is ready for releasing this beta. Are you going to post every week to ask for the next beta ? That's uselessly cluttering this forum. Please avoid such posts. But if you wait for a bata (not beta), you'll have to wait for a very long time. 😀
Dec ’24
Reply to Inform users that they need to delete and reinstall the app
There could be, with some additional development. In the new version, put code to read old data When new app launches, read data. If old data exists, automatically save in a temporary file and convert old data to new structure. delete old data in the app If you cannot convert all data, propose user to save in a file (save temporary file permanently). Otherwise, delete the temporary file. Make sure you test this extensively. It is really a bad user experience to loose data and no way to retrieve. Yo'll have to keep this mechanism in place for a few releases, as users may update only in a future release.
Dec ’24
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 ?
Topic: UI Frameworks SubTopic: UIKit
Replies
Boosts
Views
Activity
Dec ’24
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 ?
Replies
Boosts
Views
Activity
Dec ’24
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
Replies
Boosts
Views
Activity
Dec ’24
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 } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Stuck using variable in the tex statement
I do think winner is nil. Where do you call the case rule… are called. Are you sure they are ever called ? Please show complete code to allow for testing.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Stuck using variable in the tex statement
So that means winner is nil. There is likely an error here: gameIsDraw = topScorers.count > 1 winner = topScorers.count == 1 ? topScorers.first?.0 : nil gameIsDraw is true if count > 1 But winner is defined when count == 1 It should probably be winner = topScorers.count >= 1 ? topScorers.first?.0 : nil
Replies
Boosts
Views
Activity
Dec ’24
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() } } }
Replies
Boosts
Views
Activity
Dec ’24
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 ?
Replies
Boosts
Views
Activity
Dec ’24
Reply to Seeking advice on why Dog Translator Game for Dogs violates guideline 1.1.6 Safety: Objectionable Content
Including the "game" word and a notice that it is for entertainment only is not enough according to guideline 1.1.6 False information and features, including inaccurate device data or trick/joke functionality, such as fake location trackers. Stating that the app is “for entertainment purposes” won’t overcome this guideline. My understanding is that reviewer considers that some people will think they are able to speak to their dog. That's what your app name suggests with "Translator" and that could mislead users into thinking they will be able to "speak" dog. No one can give sure advice to pass review, but… At least, you could rename completely the app, eliminating the translator word. May be something like "Barking like a dog" or "Barking" ? would be more acceptable. And check that your app cannot be understood as a way to speak to a dog. Even the icon should take care of this, as well as all textes and images in the app. Good luck.
Replies
Boosts
Views
Activity
Dec ’24
Reply to Building Issue
Welcome to the forum. Is it a project (not a playground) ? Do you mean this right pointing black triangle on the right? Which version of Xcode ? Do you see a simulator selected in the top line ? What happens if you create a new project (iOS project, SwiftUI for instance) ? Do you get the triangle ? If not, you may have to reinstall Xcode
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to How to animate substring in a Text?
What do you want ? conversation/ meeting/ lecture to have always the same size ? Have the whole string with the same size ? For the later I tried using scaleEffect, which seems to be giving the expected result. struct ContentView: View { var array = ["lecture", "conversation", "meeting"] var scaleEffects = [1.0, 0.9, 1.0] // <<-- ADDED : firstString forces scale down @State var currentIndex : Int = 0 @State var firstString : String = "" @State var scale = 1.0 // <<-- ADDED var body: some View { VStack { HStack { Text("Transform") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) Text(firstString) .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) .transition(AnyTransition.opacity.animation(.easeInOut(duration:1.0))) .background(.yellow) Text("to Quick Note") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) } .padding() .frame(width: 420) .scaleEffect(x: scale, y: scale) // <<-- ADDED } .animation(.default) .onAppear { firstString = array[0] scale = scaleEffects[0] // <<-- ADDED let timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in if currentIndex == array.count - 1 { self.firstString = array[0] self.scale = scaleEffects[0] // <<-- ADDED currentIndex = 0 } else { self.firstString = array[currentIndex+1] self.scale = scaleEffects[currentIndex+1] // <<-- ADDED currentIndex += 1 } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to iOS 18.3 bata 1?
OK, you think you can manage iOS release planning ? You'll have to wait until Apple decides it is ready for releasing this beta. Are you going to post every week to ask for the next beta ? That's uselessly cluttering this forum. Please avoid such posts. But if you wait for a bata (not beta), you'll have to wait for a very long time. 😀
Replies
Boosts
Views
Activity
Dec ’24
Reply to Not displaying some websites properly after iOS 18.2
Do other websites display properly ? If so, it is possibly something in your website code that was out of spec but did work in previous iOS versions. If you show the code that should display the home page, maybe someone can find it.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Inform users that they need to delete and reinstall the app
There could be, with some additional development. In the new version, put code to read old data When new app launches, read data. If old data exists, automatically save in a temporary file and convert old data to new structure. delete old data in the app If you cannot convert all data, propose user to save in a file (save temporary file permanently). Otherwise, delete the temporary file. Make sure you test this extensively. It is really a bad user experience to loose data and no way to retrieve. Yo'll have to keep this mechanism in place for a few releases, as users may update only in a future release.
Replies
Boosts
Views
Activity
Dec ’24