Jonovono
Jonovono

Reputation: 2085

Progmatically change UIBarButtonItem identifier on UINavigationBar

So I am just using a normal View Controller. I dragged a Navigation bar to the top and added a UIBarButtonItem with the 'pause' identifier.

I want to be able to change that identifier to the 'play' one.

Is this possible? I can't find any information on it.

I tried creating a new one, but not really sure where to go from there.

    UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
                              initWithTitle:@"Flip"
                              style:UIBarButtonItemStyleBordered
                              target:self
                              action:@selector(flipView)];

Any help would be great.

Upvotes: 1

Views: 96

Answers (1)

Tommy Devoy
Tommy Devoy

Reputation: 13549

You're looking for the UIBarButtonSystemItemPlay. Just set it up, assign your selector and target, and choose which barButtonItem you want.

 UIBarButtonItem *playButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(playButtonPressed:)];
 self.navigationItem.rightBarButtonItem = playButton;//Or leftBarButtonItem if you want it to be on the left

Upvotes: 1

Related Questions