ios – Bizarre TextField habits in SwiftUi


Having this bizarre downside. At any time when I attempt to write some enter into any TextField, it retains deleting this enter. Here is the gif.

gif

Here is the code.

`import SwiftUI

struct TechniqueView: View {

// A present desplayed file
@Binding var file: TechniqueRecord

// An inventory of all data
@Binding var data: [TechniqueRecord]

// An empty placeholder word
@State personal var newNote = ""

// Determines if to indicate a conformation pop up
@State personal var showAlert = false

@Surroundings(.presentationMode) var presentation

var physique: some View {
        Listing {
            Part (header: Textual content("Primary Data")) {
                HStack {
                    Textual content("Title:")
                    TextField("Title", textual content: $file.identify)
                        .multilineTextAlignment(.trailing)

                }
                HStack {
                    Textual content("From place:")
                    Spacer()
                    Textual content(file.place)
                }
                
                TypePickerView(chosen: $file.sort)
            }
            Part (header: Textual content("Notes")) {
                ForEach($file.notes) { word in
                    HStack {
                        Picture(systemName: "record.bullet")
                        TextField("Observe", textual content: word.word, axis: .vertical)
                        Spacer()
                    }
                }.onDelete { indexSet in
                    file.notes.take away(atOffsets: indexSet)
                }.onMove(carry out: moveItem)
                
                HStack {
                    TextField("New Observe",
                              textual content: $newNote)
                    Button(motion: {
                        withAnimation {
                            let newNoteObject = TechniqueRecord.Observe(word: newNote)
                            file.notes.append(newNoteObject)
                            newNote = ""
                        }
                    }) {
                        Picture(systemName: "plus.circle")
                    }
                    .disabled(newNote.isEmpty)
                }
            }
    }

}`

I attempted including Type wrapper over record and that did not work. The factor is, I did not change code that a lot from the working model however once I reverted to that model, it did not work both.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles