Post

Replies

Boosts

Views

Activity

Reply to SwiftUI TextField corrupts selection when inserting utf16
I just tested with your new code and do not get the error. Log shows: input: changed from '' to '1' input: changed from '1' to '12' Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' input: changed from '12×' to '12×3' input: changed from '12×3' to '12×34' I run Xcode 16.4 on MacOS 15.5 (24F74) and iOS 18.4 simulator. Same with 18.5 simulator. Use hardware keyboard. With simulator virtual keyboard (on device simulator), log is different: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' No more move log, and no change from * to x. So I added a print: func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print(keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } handleKeyPress is not called with virtual keyboard on simulator. But it is with the hardware keyboard: 1 input: changed from '' to '1' 2 input: changed from '1' to '12' * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' 3 input: changed from '12×' to '12×3' 4 input: changed from '12×3' to '12×34' So I added another log: var body: some View { VStack { TextField("Type 12*34", text: $input, selection: $selection) .onKeyPress(action: {keyPress in print("onKeyPress", keyPress.key.character.unicodeScalars) return handleKeyPress(keyPress) }) .onChange(of: input) { oldValue, newValue in print("input: changed from '\(oldValue)' to '\(newValue)'") } Text("Selection: \(selectionAsString())") }.padding() } func handleKeyPress(_ keyPress: KeyPress) -> KeyPress.Result { print("handleKeyPress", keyPress.key.character.unicodeScalars) if (keyPress.key.character == "*") { insertAtCursor(text: "×") moveCursor(offset: 1) return KeyPress.Result.handled } return KeyPress.Result.ignored } With hardware keyboard, log is: onKeyPress 1 handleKeyPress 1 onKeyPress 2 handleKeyPress 2 input: changed from '' to '1' input: changed from '1' to '12' onKeyPress * handleKeyPress * Moving cursor from 2[any] Moved to 4[utf8] input: changed from '12' to '12×' onKeyPress 3 handleKeyPress 3 input: changed from '12×' to '12×3' onKeyPress 4 handleKeyPress 4 input: changed from '12×3' to '12×34' with simulator virtual keyboard, log is: input: changed from '' to '1' input: changed from '1' to '12' input: changed from '12' to '12*' input: changed from '12*' to '12*3' input: changed from '12*3' to '12*34' Which shows onKeyPress is not called either. Surprising. But confirmed here: https://stackoverflow.com/questions/79198074/onkeypress-doesnt-work-on-textfield-foreach-array
Topic: UI Frameworks SubTopic: SwiftUI
Jun ’25
Reply to Having trouble posting
I once had a similar issue: https://developer.apple.com/forums/thread/779778 It seems the anti spam is oversensitive. You have to try and find the "offensive" word (in my case it was the word "f r e e" !) and adapt by adding spaces between the letters. Another way is to capture a screenshot of the prepared post, and attach the image ! Not exactly user friendly. And you could also post a bug report.
Jun ’25
Reply to Guideline 2.1 - Information Needed
Just one advice, hope that helps. Reviewer may be different at each review. So it may be useful to remind (concisely) what you describe here, in the Info to reviewer section so that he/she knows what you've done so far and doesn't think that this is a problematic app, just seeing you got several rejections..   another point: The reviewer likely didn’t notice that the country code is pre-filled and tried entering it manually So probably, some users will do the same error. Can you catch it and alert if user makes the mistake ?
Jun ’25
Reply to App Name capitalization issue
If it may help… I tested an app by changing the Bundle Display name to 1on1SimpleTest. And it displays correctly on iPhone (loaded from Xcode, not AppStore however). Also tested with a space: 1on1 Simple: display correctly. Note: if the name is too long, however, the space is removed: 1on1 SimpleTest 21 displays as 1on1SimpleTest 21
Jun ’25
Reply to Conditionally Adding and Deleting a Row in a UITableView
That's clearer. You are not adding or deleting row, but show or hide a TextField. Declare in storyboard a UITextField, positioned just below the segmented control. Declare it as hidden in the storyboard. Define its delegate (the viewController). Define placeholder as: enter custom tip declare an IBOutlet for this UITextField : tipTextField for instance there is an IBAction associated to the SegmentedControl (valueChanged event) in the IBAction, test for the selection @IBAction func segmentSelection(_ sender: UISegmentedControl) { let selection = sender.selectedSegmentIndex if selection == sender.numberOfSegments - 1 { // The last segment = Any tipTextField.isHidden = false } else { tipTextField.isHidden = true // store the relevant value in a tipValue property } } You should also define and IBAction for the textField, (for EditingDidEnd and for didEndOnExit), that will read the text you have entered and convert to Int to get the tip value. Then save this value in a tipValue property of the ViewController. Hope that helps. Don't forget to close the thread if OK. Otherwise, explain what you are missing.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’25
Reply to Conditionally Adding and Deleting a Row in a UITableView
It is not very clear. Could you post a sketch showing: what are the options (custom and another)? Are there 2 buttons ? Or only one button which behaviour should change depending on the slider value ? which another option is it ? Is the TextField inside TableView row ? when the custom option is tapped, bring up a row immediately below there and have a UITextField You bring up a new row ? Or an existing one ? do you add a TextField, or was it already in the row ? When another option, let's say 10%, is tapped, I want the text field row to go away. Do you want to delete the row ? Or just hide it ? If there is only one button which behaviour change depending on the slider value: in the button action, you test the value of slider if 20% or more, then call mytableView.insertRows(at…) if less, then call mytableView.deleteRows(at…) In both cases, don't forget to update the dataSource.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’25
Reply to App name
If the name is not in the app store, why can't I use the name? May be it is the name of an app available only in another region ; hence you don't see it when you query the appstore from your region ? You should contact Apple support to get clarification.
Jun ’25