Question

Consider the following scenario:

  • When entering view, back-button is normal, (left-arrow).
  • Once user has started adding stuff to a list, the button becomes a trashcan in order to tell the user that progress is lost if back-button is pressed.

Is it possible to make the back-button listen to a list and change once it has one or more elements?

I have tried

[UIBarButtonItem appearance] setBackButtonBackgroundImage;

But that changes the back-button in the whole application… and I only want it changed in the current view.

Était-ce utile?

La solution

[UIBarButtonItem appearance] is a proxy used to globally set appearance settings

You should use self.navigationItem.backBarButtonItem to set the image for a given view controller

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top