Reputation: 387
I need a basic UITableView with key and value. I modify each cell to contain a UILabel, and a UITextArea. My problem is when I click the cell, the cell gives the blue click-response, but the keyboard does not appear, and the UITextField is not showing any response for editing.
In - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath I can get the textField, and set text to it, but I want to open the keyboard for writing in the textField.
When I modify the cell, I set all UITextFields to firstResponder, without luck.
Anyone?
Upvotes: 0
Views: 1511
Reputation: 677
I looked up one of my older projects and found out I handled things a little different back then. Here is what I did:
cell = [self.aTableView dequeueReusableCellWithIdentifier:kPlaceCell];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier:kPlaceCell] autorelease];
}
//PlaceField = An Instance of UITextfield, which I implemented as classvar.
[self.placeField removeFromSuperview];
// setting frame and font for your textfield. If you have static text in your Textlabel you should have an higher x so maybe CGRectMake (1, 100, 218, 39)
self.placeField.frame = CGRectMake(1, 1, 318, 39);
self.placeField.font = [UIFont boldSystemFontOfSize:18.0f];
//Adding your UITextfield to the UITableViewCell contentView
[cell.contentView addSubview: self.placeField];
}
If anyone wonders: I used this tableView so that the user can create an user account and used Placeholders for (Name, Date of birth,....) so I didn't need static text. ^^
Tell me how this works for you or if you need further explanations
Upvotes: 0
Reputation: 677
As far as I remember, you can use the UITableViewStyleValue1 and just set the detailTextlabel to be an UITextlabel in your CellForRow. But take care that the TextLabel has a fitting width and height. Then you dont have to select the Cell but can directly tap the UITextLabel
Upvotes: 0