Post not yet marked as solved
I have reported this to Apple during WWDC'21 and have not touched the code since then. I might be working now, or not, I'd have to check...
What do you need exactly, @TikiMcFee ? Maybe I can give you some code examples 😀
Post not yet marked as solved
Worked for me as well, thanks!! Congratulations, Gian Enrico @ingconti and grazie mille!
PS: Curious thing is, my build was working in Xcode 11, and broke on Xcode 12.
Hi, cederachBiB,Did a small change to your code that I'd like to share back. I was having problems with TextFieldWithFocus filling up too much space when I wanted a single-line TextField similar to SwiftUI's.I tried adding a .frame(height: ) to my TextFieldWithFocus element, but it crashed the app. So I added this code to the end of the properties and beginning of the makeUIView(context:) var enablesReturnKeyAutomatically: Bool = false
@State var frameRect: CGRect = .zero
var onCommit: (() -> Void)?
func setFrameRect(_ rect: CGRect) -> some View {
self.frameRect = rect
return self
}
func makeUIView(context: UIViewRepresentableContext) -> UITextField {
let textField = UITextField(frame: self.frameRect)
textField.delegate = context.coordinator
textField.placeholder = NSLocalizedString(placeholder, comment: "")And by using a GeometryReader around the element (or elements in a HStack), it's now possbile to set the frame this way, for example:GeometryReader { geometry in
HStack {
TextFieldWithFocus(text: self.$newString, placeholder: "placeholder", isFirstResponder: self.$textHasFocus,
onCommit: { UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil,
from: nil, for: nil)
self.textHasFocus = false
})
.setFrameRect(geometry.frame(in: .global))
.frame(height: 36)
.border(Color.black, width: 1)
.padding(.horizontal)
...
}Hope this can be of use, and thanks again for sharing your fix to our problem!Best, Tarq
Thank you for sharing, cederacheBiB 😀
I'm having the same problem here. It captures 2-3 letters, then disconnects...
Thanks, you're the best!i Will do that 😊
Thanks for the prompt answer, eskimo,Im a big fan of yours, BTW! See really helpful answers from you all the time 😎One litlte extra help, if you can: most SwiftNIO tutorials I found so far seem to focus only on HTTPS post and/or websockets. Can you suggest any tutorials on SwiftNIO for data streams? Something like WWDC's Tic-Tac-Toe example would be perfect, it really helped along with my coding!Best, Tarq