I was trying to add UIToolBar into a UIWebView but whenever I insert this code inside viewDidLoad UIToolBar doesn't show up, however when this is done in viewWillAppear, it works. Can someone please explain it to me.
-(void)viewDidLoad
{
[super viewDidLoad];
self.forwardButton = [[UIBarButtonItem alloc]initWithTitle:@"Forward" style:UIBarButtonItemStylePlain target:self action:@selector(forward)];
self.backButton = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(back)];
NSArray *buttonsArray = @[self.backButton,self.forwardButton];
CGRect toolBarFrame = CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44);
self.toolbar = [[UIToolbar alloc]initWithFrame:toolBarFrame];
[self.toolbar setItems:buttonsArray animated:YES];
[self.toolbar sizeToFit];
[self.view addSubview:self.toolbar];
}