How to add a right button to a UINavigationController?

后端 未结 21 1168
不思量自难忘°
不思量自难忘° 2020-11-28 18:25

I am trying to add a refresh button to the top bar of a navigation controller with no success.

Here is the header:

@interface PropertyViewController          


        
21条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 18:51

    Also you are able to add multiple buttons using rightBarButtonItems

    -(void)viewDidLoad{
    
        UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithTitle:@"button 1" style:UIBarButtonItemStylePlain target:self action:@selector(YOUR_METHOD1:)];
        UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithTitle:@"button 2" style:UIBarButtonItemStylePlain target:self action:@selector(YOUR_METHOD2:)];
    
        self.navigationItem.rightBarButtonItems = @[button1, button2];
    }
    

提交回复
热议问题