How to add right button in the navigation bar?

前端 未结 6 626
傲寒
傲寒 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:09

    Add below code in viewDidLoad Method

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

    This adds a button to the right hand side with the title Flip, which calls the method:

    -(IBAction)flipView
    

提交回复
热议问题