IOS add right button function example code

Time:2022-5-19

1、 Drawing.

2、 Code.

ViewController.m

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  
  //Add right button
  [self addRightButton];
}
#pragma -mark -functions
//Add right button
-(void)addRightButton
{
  Uibarbuttonitem * selectbutton = [[uibarbuttonitem alloc] initwithtitle: @ "filter" style: uibarbuttonitemstyledone target: self action: @ selector (doclickrightbutton)];
  self.navigationItem.rightBarButtonItem = selectButton;

}
#pragma -mark -doClickAction
-(void)doClickRightButton
{
  FirstViewController *first=[[FirstViewController alloc]init];
  [self.navigationController pushViewController:first animated:NO];
}

The above is the example code of IOS button function added on the right introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support to the developeppaer website!