How to add Bar Button in navigation bar without navigation controller.

前端 未结 3 1014
遥遥无期
遥遥无期 2021-01-02 20:15

I am new to iOS development.I have create a navigation bar in my iPad application view.I don\'t need navigation controller that\'s why i have added only navigation bar. Now

3条回答
  •  难免孤独
    2021-01-02 20:52

    You can add buttons to navigation bar as follows:

    UIBarButtonItem *btnSave = [[UIBarButtonItem alloc] 
                                    initWithTitle:@"Save"
                                    style:UIBarButtonItemStyleBordered 
                                    target:self 
                                 action:@selector(save_Clicked:)];
     navBar.rightBarButtonItem = btnSave;
     [btnSave release];
    
     UIBarButtonItem *btnCancel = [[UIBarButtonItem alloc] 
                                    initWithTitle:@"Cancel"                                    
                                    style:UIBarButtonItemStyleBordered
                                    target:self
                                    action:@selector(cancel_Clicked:)];
     navBar.leftBarButtonItem = btnCancel;
     [btnCancel release];
    

提交回复
热议问题