I want to change the title of a bar button (right navigation) from login to sign up depending on which the user checks.
Previously, I had this as a button in the VC and it worked with the following code:
[_submitButton setTitle:@"Sign Up" forState:UIControlStateNormal];
However, now that I've deleted the button in the page and have given the bar button the name submitButton, I am getting the following error:
No visible @interface for 'UIBarButtonItem' declares the selector 'setTitleForState'
Does anyone know why this is not working? Do I have to name uibarbutton something different than a regular button?
UIBarButtonItem
is not UIButton
Please check the following:
_submitButton
, you will see a popover with declaration and type.UIBarButtonItem
, you will see the documentation.UIBarButtonItem
is a subclass of UIBarItem
UIBarItem
There is a title
property without further arguments, so it's
_submitButton.title = @"Sign Up";
Reading the documentation is very important, it's impossible to remember all properties/methods of all classes but it's the first thing you should do if you get an error message like this.