How to add right button in the navigation bar?

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

    - (void)viewDidLoad {
    
        [super viewDidLoad];
        UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc]initWithTitle:@"Right Button" style:UIBarButtonItemStyleDone target:self action:@selector(rightBtnClick)];
        self.navigationItem.rightBarButtonItem = rightBtn;
    }
    
    -(void)rightBtnClick{
        // code for right Button
    
    }
    

提交回复
热议问题