Hide the rightBarButtonItem of a navigation controller

前端 未结 3 1539
盖世英雄少女心
盖世英雄少女心 2021-02-19 03:45

Does anyone know how to hide a rightBarButtonItem of a UINavigationController? In my application, I have an edit button as a rightBarButtonItem

3条回答
  •  甜味超标
    2021-02-19 04:16

    Try

    self.navigationItem.rightBarButtonItem = nil;
    

    When you want it back though you will have to instanciate a button i.e.

    UIBarButtonItem *rightBarButton = 
     [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch
                                                   target:self
                                                   action:@selector(searchBar:)];
    self.navigationItem.rightBarButtonItem = rightBarButton;
    [rightBarButton release];
    

提交回复
热议问题