简体   繁体   中英

showing toolbar buttons on a navigation controller

hi i know i'm missing something because it seems pretty easy all over the web. I'm adding buttons to my toolbar,
the toolbar is showing. but without any buttons.
this is my code :

    - (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"secondPage";
    UIBarButtonItem *deleteAllItem = [[[UIBarButtonItem alloc] initWithTitle:@"Delete All"
                                                                       style:UIBarButtonItemStyleBordered   
                                                                      target:self
                                                                      action:@selector(deleteAllAction:)] autorelease];


    UIBarButtonItem *searchNearbyItem = [[[UIBarButtonItem alloc] initWithTitle:@"Search Nearby"
                                                                          style:UIBarButtonItemStyleBordered
                                                                         target:self
                                                                         action:@selector(searchNearbyAction:)] autorelease];

    [self.navigationController setToolbarHidden:NO];
    self.toolbarItems = [NSArray arrayWithObjects: 
                      deleteAllItem,
                      searchNearbyItem,
                      nil];

} 

Thank you for your help

Have you tried setting the items via:

- (void)setItems:(NSArray *)items animated:(BOOL)animated

Note: Be sure to set this on your view controller, do not set it on the UIToolbar instance directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM