yannisalexiou
yannisalexiou

Reputation: 707

Change the title of an IBAction from another IBAction

I'm wondering how to call an IBAction from another IBAction. What I want to do is when I touch a button on previousPage, the title of the nextPage button to change. In other words I have these IBActions:

- (IBAction)nextPageButtonItemPressed:(UIBarButtonItem *)sender
{
  ...
}

- (IBAction)previousParageButtonItemPressed:(UIButton *)sender
{
  //This is what i want to do
  [self nextPageButtonItemPressed:sender.title = @"Next Page"];
}

I have also created an IBOutlet of previousPage.

@property (strong, nonatomic) IBOutlet UIToolbar *nextPageOutlet;

But I can't find the way to do this.

P.S. The nextPage is a button in UIToolbar.

Upvotes: 0

Views: 267

Answers (1)

LyricalPanda
LyricalPanda

Reputation: 1414

For this, you need to have your UIButton as an IBOutlet property.

So something like:

@property (nonatomic, retain) IBOutlet UIBarButtonItem *previousButton;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *nextButton;


- (IBAction)nextPageButtonItemPressed:(UIBarButtonItem *)sender
{
  ...
}

- (IBAction)previousPageButtonItemPressed:(UIBarButtonItem *)sender
{
  self.nextButton.title = @"Next Page"; 
}

Upvotes: 1

Related Questions