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

前端 未结 3 2010
感情败类
感情败类 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 05:48

    Just set it nil

    [self.navigationItem setLeftBarButtonItem:nil animated:YES];
    
    0 讨论(0)
  • 2021-01-14 05:58
    self.navigationItem.rightBarButtonItem = nil;
    
    0 讨论(0)
  • 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];
    
    0 讨论(0)
提交回复
热议问题