How to add right button in the navigation bar?

前端 未结 6 625
傲寒
傲寒 2021-02-05 16:40

I have a question to add a right button in navigation bar..

I have two views: View A and View B

I add a navigation bar to view A, after I used self.navigat

6条回答
  •  [愿得一人]
    2021-02-05 17:10

    You can add the following code to your B controller's viewDidLoad method.

    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Title" 
                                                                        style:UIBarButtonItemStyleDone 
                                                                        target:self 
                                                                        action:@selector(rightButtonAction:)];
    self.navigationItem.rightBarButtonItem = rightButtonItem;
    

提交回复
热议问题