0

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;
    }
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
AbuZubair
  • 1,236
  • 14
  • 20
  • 4
    why not you make use of custom cell. – Leena Dec 04 '12 at 08:27
  • Argghh, this was my problem. I was dequeue-ing with static cells! Thanks Leena.: http://stackoverflow.com/questions/9993669/storyboard-static-cells-dequeuereusablecellwithidentifier-returns-nil – AbuZubair Dec 04 '12 at 17:48

0 Answers0