jeudi 11 juillet 2019

Update subviews of UIView from ViewController

I have a UIViewController that implements a custom UIView, so;

override func loadView() {
    view = CustomView()
}

The custom view has a few lables and buttons and all the normal stuff, problem is in my viewController I have a request, and when that request is done, I'd like to update some of those lables/buttons.

Right now, in my CustomView, I have functions, such as;

func updateView() {
    labelOne.isHidden = true
    LabelTwo.isHidden = false
}

So I call the appropriate function from my viewController when the request is done.

This works, but it feels wrong, is there a neater way to update the subviews of my custom UIView, from my viewController? Should I maybe be using protocols or delegates?

Aucun commentaire:

Enregistrer un commentaire