This topic has been discussed several times and I am aware of how to create a UITextField
inside of a UITableViewCell
.
I know that with a UITableViewController
that is using prototype cells, I have to create a custom sub class of UITableViewCell
and then hook up UITextField
I created through IB
into the subclass.
Why is it with using static table view cells, I have to programatically create the UITextField? I could find no way to use the IB to create a UITextField for my static table view cells.
It seems that interface builder is useless when trying to drag and create a UITextField when working with static table view cells. Does anyone know why?
I hate having to resort to code like this for static cells when IB would do it for me with prototype cells:
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, -2, 650, 18)];
textField.placeholder = @"Enter Text";
[textField setFont:[UIFont fontWithName:@"System" size:16]];
textField.backgroundColor = [UIColor clearColor];
textField.delegate = self;
textField.highlighted = NO;
cell.accessoryView = textField;
}