I have a button that throughout the program he changes his name.
original name is \"line\".
is then renamed to \"bar\".
When is named \"bar\" and I press it
The problem is that you are setting _bt3.titleLabel.text
directly. Don't do that.
A button has states: normal, highlighted, selected, and disabled. It knows what its text should be for each state. When _bt3
changes state, it sets _bt3.titleLabel.text
. This overrides your change to _bt3.titleLabel.text
.
If you don't set the text for a non-normal state, the button uses the text for the normal state.
When the user touches _bt3
, _bt3
changes its state to highlighted and sets _bt3.titleLabel.text
to the text set for its highlighted state. When the user stops touching _bt3
, _bt3
changes its state back to normal and sets _bt3.titleLabel.text
to the text set for its normal state.
So instead of setting _bt3.titleLabel.text
directly, you need to tell the button what text it should display in the normal state:
[_bt3 setTitle:@"Bar" forState:UIControlStateNormal];