iPhone App :
- i have a screen with 3 textfields to enter name, email and location.
- i have used grouped table view with 2 sections.
- in tat first section has three cells.. each cell has a label n a textfield.. eg: label called name and a text box to enter name.. like wise i have it for email and location too..
HAVE DECLARED nameTextField, emailTextField, locationTextField in the interface as variables and not properties. so pls tell me how to dismiss the keyboard here
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CommonTableViewCell* cell = [[CommonTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@""];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.highlightedTextColor = [UIColor whiteColor];
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:14];//
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
//cell.image = [UIImage imageNamed:@"resources_on.png"];
cell.textLabel.frame = CGRectMake(TABLE_ROW_HEIGHT + 10, 5, self.view.frame.size.width , 25);
if (indexPath.section == 0) {
if (indexPath.row == 0) {
cell.textLabel.text = @"Username";
nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(140, 18, 300, 20)];
[nameTextField setBackgroundColor:[UIColor clearColor]];
[nameTextField setFont:[UIFont fontWithName:@"Arial" size:14]];
nameTextField.placeholder = @"Enter anonymous name";
[nameTextField setKeyboardType: UIKeyboardTypeNamePhonePad];
[cell addSubview:nameTextField];
[nameTextField release];
}else if (indexPath.row == 1) {
cell.textLabel.text = @"Email";
emailTextField = [[UITextField alloc] initWithFrame:CGRectMake(140, 18, 300, 20)];
[emailTextField setBackgroundColor:[UIColor clearColor]];
[emailTextField setFont:[UIFont fontWithName:@"Arial" size:14]];
emailTextField.placeholder = @"example@me.com";
[emailTextField setKeyboardType:UIKeyboardTypeEmailAddress];
[cell addSubview:emailTextField];
[emailTextField release];
}else if (indexPath.row == 2) {
cell.textLabel.text = @"Location";
locationTextField = [[UITextField alloc] initWithFrame:CGRectMake(140, 18, 300, 20)];
[locationTextField setBackgroundColor:[UIColor clearColor]];
[locationTextField setFont:[UIFont fontWithName:@"Arial" size:14]];
locationTextField.placeholder = @"Fetch";
[cell addSubview:locationTextField];
[locationTextField release];
}else if (indexPath.row == 3) {
cell.textLabel.text = @"Terms of Use";
cell.thumbnailView.image = [UIImage imageNamed:@"compensation_on.png"];
}else if (indexPath.row == 4) {
cell.textLabel.text = @"Privacy Policy";
cell.thumbnailView.image = [UIImage imageNamed:@"compensation_on.png"];
}else {
}
} else if (indexPath.section == 1) {
if (indexPath.row == 0) {
cell.textLabel.text = @"Terms of Use";
cell.thumbnailView.image = [UIImage imageNamed:@"compensation_on.png"];
}else if (indexPath.row == 1) {
cell.textLabel.text = @"Privacy Policy";
cell.thumbnailView.image = [UIImage imageNamed:@"compensation_on.png"];
}else {
}
}
return cell;
}
and this isnt working for me..
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}