add buttons(from code) on the Navigation Controller and make them disappear

前端 未结 3 2012
感情败类
感情败类 2021-01-14 05:13


I have added a button from the code above \"view controller\":

@implementation HBViewController
.....
.....
.....

- (void)viewDidLoad
{
    [super view         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 06:04

                //to disable
    
            self.navigationItem.rightBarButtonItem.enabled = NO;
    
                //to hide - hide means setting nil will remove that button
    
            self.navigationItem.rightBarButtonItem = nil;
    
    
                //if u want to show again then create and assign new button again
    
            okButton = [[UIBarButtonItem alloc] initWithTitle:@"Ok" 
    
                      style:UIBarButtonItemStyleBordered
    
                      target:self action:@selector(okayButtonPressed)];
    
            [self.navigationItem setRightBarButtonItem:okButton animated:NO];
    

提交回复
热议问题