title: How I tell my UITextField (code) to resign first responder?
body: <p>I have created my UITextField by code, without InterfaceBuilder. I want the keyboard to disappear when the button "Done" is pushed. How does the code know that I am referending to an UITextField and no to other one</p>
  
  <hr>
  
  <p>First, thanks a lot.</p>
  
  <p>My code is like this:</p>
  
  <pre><code>-(void)viewDidLoad {
      [super viewDidLoad];
      field = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 185, 30)];
      field.adjustsFontSizeToFitWidth = YES;
      field.textColor = [UIColor blackColor];
      field.placeholder = @"Text";
      field.keyboardType = UIKeyboardTypeDefault;
      field.returnKeyType = UIReturnKeyDone;
      field.backgroundColor = [UIColor blueColor];
      field.delegate = self;
      [self.view addSubview:field];
  } 
  
  ......
  
  -(BOOL)textFieldShouldReturn:(UITextField *)textField
  {
      [textField resignFirstResponder];
  
  }
  </code></pre>
  
  <p>With this code I push the button Done and nothing happen. Is like that how you say?</p>
  
  <p>Edit:</p>
  
  <p>I've created two UITextField how I did with the previous one. But now, for each row I do this: </p>
  
  <pre><code> if ([indexPath row] == 0) {
       [cell.contentView addSubview:pTextField];
   }
   else {
       [cell.contentView addSubview:pTextField];
   }
  </code></pre>
  
  <p>So with this code, the program received signal "EXC_BAD_ACCESS". Any idea why happen this?</p>