I am programmatically adding some toolbar items to a view in a UIViewController 
subclass, and it only seems to work when I put the code in viewWillAppear:

 // add a toolbar with a prev and next button
    self.navigationController.toolbarHidden = NO;
    UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target: self 
action: nil];
    self.prevButton = [[UIBarButtonItem alloc] initWithTitle: @"Prev" style: 
UIBarButtonItemStyleBordered target: self action: nil];
    self.nextButton = [[UIBarButtonItem alloc] initWithTitle: @"Next" style: 
UIBarButtonItemStyleBordered target: self action: nil];
    
    self.toolbarItems = [NSArray arrayWithObjects: self.prevButton, 
flexibleItem, self.nextButton, nil];

If I put it in viewDidLoad, the toolbar never shows up.  In the book by Conway 
and Hillegass (3rd ed), they put similar code in init, but that also doesn't 
work in my case. Interestingly, I am adding a UISearchBar in init, and that 
works just fine.

Why is that? Is viewWillAppear the recommended place to do this?

- Koen.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to