skip to Main Content

Such a problem: I write text in a TextField, for example, a ДОМИК , and when I go through the button (it did not get into the frame) to the main screen -> menu -> Add. Then this text is saved.

What I tried: 1 – do not save to coredata – the text remains anyway.
2-using print, I output a list where I store the textfield. The first time before entering it shows [] an empty array, and when I go through the controllers again to this screen, it shows nothing. As if the screen is not readable.

I need after each click on the menu-an updated controller, that is, an empty one, without a user-filled UITextField

enter image description here

func didSelect(menuItem: MenuViewController.MenuOptions) {
    toggleMenu { [weak self] in
        switch menuItem {
        case .home:
            self?.resetToHome()
        case .calendarPay:
            break
        case .statistics:
            break
        case .addProperty:
            self?.addProperty()
        case .settings:
            break
        }
    }
}


func addProperty() {
    let vc = addVC
    homeVC.addChild(vc)
    homeVC.view.addSubview(vc.view)
    vc.view.frame = view.frame
    vc.didMove(toParent: self)
    vc.delegate = homeVC
}

2

Answers


  1. As I see it, you need an empty textField every time you visit the textField’s ViewController and to achieve the same you need to set textField’s text value as empty. So when you visit or present the controller over screen the textField would be set to empty.

    vc.textField.text = ""
    
    Login or Signup to reply.
  2. Try adjusting the code:

    func addProperty() {
        let vc = "you addVC".init()
        //...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search