title: Adding Next/Done buttons to NumberPad on IOS?
body: <p>I need to implement next/done buttons to number pad.</p>
  
  <p>I am using the code below.</p>
  
  <p>But i am taking an exception while selecting keyboard view. index 1 beyond bounds [0...0]</p>
  
  <p>Here is my code;</p>
  
  <pre><code>//doneButton initialisation
  doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
  doneButton.frame = CGRectMake(0, 163, 106, 53);
  doneButton.adjustsImageWhenHighlighted = NO;
  [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
  [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
  [doneButton addTarget:self action:@selector(textFieldShouldReturn:) forControlEvents:UIControlEventTouchUpInside];
  
  
  //the exception i am taking
  else if(textField == cardNumberField)
  {
  
      UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
      UIView* keyboard;
      for(int i=0; i&lt;[tempWindow.subviews count]; i++) {
          keyboard = [tempWindow.subviews objectAtIndex:i];
          // keyboard view found; add the custom button to it
          if([[keyboard description] hasPrefix:@"&lt;UIKeyboard"] == YES) {
              [keyboard addSubview:doneButton];
          }
      }
  
      [mainScrollView setContentSize:CGSizeMake(0, mainScrollView.contentSize.height+185)];
  
      [mainScrollView setContentOffset:CGPointMake(0, mainScrollView.frame.origin.y+185)];
  }
  </code></pre>