title: I'm trying to add a toolbar dynamically but not sure how to get access to the view controller to add tool bar view
body: <p>I'm new to this...</p>
  
  <p>I have a view controller based on a UITableView 
  .h file </p>
  
  <pre><code>@interface OAFeaturesViewController : UITableViewController&lt;PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate&gt; 
  </code></pre>
  
  <p>I can create / add the toolbar but it winds up attached to the tableView when i use        </p>
  
  <p>[self.view addSubview:myToolBar];</p>
  
  <p>How do I get a reference to the main window so I can add it to the bottom of the main screen where it belongs?<br>
  .m file</p>
  
  <pre><code>UIToolbar *myToolBar = [[UIToolbar alloc]init];
  myToolBar.frame = CGRectMake(0,0,430, 44);
  UIBarButtonItem *takePicButton = [[UIBarButtonItem alloc] initWithTitle:@"Take Pic" style:(UIBarButtonItemStyleBordered) target:self action:@selector(takePictureWithCamera)];
  
  UIBarButtonItem *cancelPicButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:(UIBarButtonItemStyleBordered) target:self action:@selector(cancelPictureWithCamera)];
  
  
  NSArray *items = [NSArray arrayWithObjects: takePicButton, cancelPicButton, nil];
  [myToolBar setItems:items animated:NO];
  </code></pre>
  
  <p>[self.view addSubview:myToolBar];</p>
  
  <pre><code>UIImage *toolbarBkg = [[UIImage imageNamed: @"Navbar_background_solidblue.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
  
  if ([myToolBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)])
  {
      [myToolBar setBackgroundImage:toolbarBkg forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
      NSLog(@"toolbar responds to selector");
  }
  else {
      NSLog(@"toolbar does NOT respond to selector");
      UIImageView *background = [[UIImageView alloc] initWithImage:toolbarBkg];
      background.frame = myToolBar.frame;
      [myToolBar insertSubview:background atIndex:0];
  
  }
  
  
  [self.view  bringSubviewToFront:myToolBar];
  </code></pre>