Search code examples
swiftxcodecontrolleruitextfield

The controller is not being updated


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
}

Solution

  • Try adjusting the code:

    func addProperty() {
        let vc = "you addVC".init()
        //...
    }