I have UIBarButto item i want that when app open it should say login which works fine and when i click on login it does not call method on first click but when i again click then it works and also when view is change and we move to another view and come back to this it should be title of BarButtonItem Logout becuase you have login and you are on the other view so no need to login again any idea how to fix this issue .I am using the following code
thanks
- (void) loginPressed
{
if (loginCheck)
{
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(loginPressed)];
popImageView.hidden=NO;
passwordLabel.hidden=NO;
userLabel.hidden=NO;
userNameTextField.hidden=NO;
userPasswordTextField.hidden=NO;
signInButton.hidden=NO;
tableView.hidden=YES;
}
else
{
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStyleBordered target:self action:@selector(loginPressed)];
popImageView.hidden=YES;
passwordLabel.hidden=YES;
userLabel.hidden=YES;
userNameTextField.hidden=YES;
serPasswordTextField.hidden=YES;
signInButton.hidden=YES;
tableView.hidden=NO;
}
loginCheck = !loginCheck;
}
- (void)viewWillAppear:(BOOL)animated
{
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStyleBordered target:self action:@selector(loginPressed)];
self.title=@"Activity";
[super viewWillAppear:animated];
}