title: placing a UIToolbar over the Keyboard in Xcode 4.3
body: <p>This is my first post and I am quite new to programming in the iOS.  I am using xcode 4.3 and have what is probably an easy question.  I have looked all over for a way to place a toolbar above the keyboard that has a prev/next button on it.  I have found several tuts on how to do this when xcode was using the interface builder.  But I can not find one that is for the newest version of xcode.  So I have taken what I have found on the internet and from the Apple dev site and came up with some code.  The only thing is, it doesn't work!  I get an error that says assignment to readonly property on the lines with the inputAcessoryView.  I know that it is probably something simple, but when transfering the code from the previous version to the newer version, I most likely messed something up.  Could someone check out my code and let me know what I did wrong.  Thanks so much. I have included  my .h/.m files</p>
  
  <pre><code>    #import &lt;UIKit/UIKit.h&gt;
  
      @interface keyboardViewController : UIViewController
  
  
      @property (retain, nonatomic) IBOutlet UIView *textField1;
      @property (retain, nonatomic) IBOutlet UIView *textField2;
  
      @property (nonatomic, retain) UIToolbar *keyboardToolbar;
  
      -(void)resignKeyboard:(id)sender;
      -(void)previousField:(id)sender;
      -(void)nextField:(id)sender;
  
      @end
  </code></pre>
  
  <p>implimentation</p>
  
  <pre><code>    #import "keyboardViewController.h"
  
      @interface keyboardViewController ()
  
      @end
  
      @implementation keyboardViewController
      @synthesize textField1;
      @synthesize textField2;
      @synthesize keyboardToolbar;
  
      - (void)viewDidLoad
      {
          [super viewDidLoad];
  
          if (keyboardToolbar == nil)
          {
              keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0,                            self.view.bounds.size.width, 44)]; 
  
              UIBarButtonItem *previousButton = [[UIBarButtonItem alloc] initWithTitle:@"previous" 
                                                                                 style:UIBarButtonItemStyleBordered
                                                                        target:self 
                                                                        action:@selector(previousField:)];
              UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"next" 
                                                                             style:UIBarButtonItemStyleBordered
                                                                            target:self 
                                                                            action:@selector(nextField:)];
  
              UIBarButtonItem *extraSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemFlexibleSpace) target:nil action:nil];
  
  
              UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemDone) target:self action:@selector(resignKeyboard:)];
  
  
  
              [keyboardToolbar setItems:[[NSArray alloc] initWithObjects:previousButton, nextButton, extraSpace, done, nil]];
  
              textField1.inputAccessoryView  = keyboardToolbar;
              textField2.inputAccessoryView  = keyboardToolbar;
  
  
          }
  
  
      }
  
      -(void) resignKeyboard:(id)sender
      {
          if ([textField1 isFirstResponder])
              [textField1 resignFirstResponder];
  
          else if ([textField2 isFirstResponder])
          [textField2 resignFirstResponder];
      }
  
      -(void) previousField:(id)sender
      {
          if ([textField1 isFirstResponder])
              [textField2 becomeFirstResponder];
  
          else if ([textField2 isFirstResponder])
              [textField1 becomeFirstResponder];
      }
  
  
      -(void) nextField:(id)sender
      {
          if ([textField1 isFirstResponder])
              [textField2 becomeFirstResponder];
  
          else if ([textField2 isFirstResponder])
              [textField1 becomeFirstResponder];
      }
  
  
      - (void)viewDidUnload
      {
          [self setTextField1:nil];
          [self setTextField2:nil];
          [self setKeyboardToolbar:nil];
          [super viewDidUnload];
          // Release any retained subviews of the main view.
      }
  
      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
          return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
      }
  
      @end
  </code></pre>