Grouped style setting not taking effect from IB, UITableView
iphone, iphone-sdk-3.0, objective-c, uitableview
Solution
Still not sure why the "grouped" style setting is not taking effect from the Interface Builder. However, you can manually set it before the view is created here:
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
style = UITableViewStyleGrouped;
if (self = [super initWithStyle:style]) {
}
return self;
}
Problem
I've created a table view in an iPhone app using Interface Builder (IB). My table style is set to Grouped, and displays that way in IB. However, whenever I build and run, it shows up as a Plain style in the simulator. I have another view set to Grouped and don't experience this problem. Has anyone run into this problem before? The rest of the view is not created programmatically, so I'd like to avoid doing that for this view. There must be something I'm missing. The only tableView method I'm doing much of anything in is the cell handler method where I'm incorporating a text box into select fields: ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; } if (indexPath.section == 0) { if (indexPath.row == 0) { cell.textLabel.text = @"Title"; UITextField *listTitleTextField = [ [ UITextField alloc ] initWithFrame: CGRectMake(150, 10, 145, 38) ]; listTitleTextField.adjustsFontSizeToFitWidth = YES; listTitleTextField.textColor = [UIColor blackColor]; listTitleTextField.font = [UIFont systemFontOfSize:17.0]; listTitleTextField.placeholder = @"Your Title"; listTitleTextField.backgroundColor = [UIColor whiteColor]; listTitleTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support listTitleTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support listTitleTextField.textAlignment = UITextAlignmentRight; listTitleTextField.keyboardType = UIKeyboardTypeDefault; // use the default type input method (entire keyboard) listTitleTextField.returnKeyType = UIReturnKeyDone; listTitleTextField.tag = 0; listTitleTextField.delegate = self; listTitleTextField.clearButtonMode = UITextFieldViewModeUnlessEditing; // no clear 'x' button to the right if (self.wishList.listTitle == nil || [self.wishList.listTitle length] == 0) { listTitleTextField.text = @""; } else { listTitleTextField.text = self.wishList.listTitle; } [listTitleTextField setEnabled: YES ]; [cell addSubview: listTitleTextField ]; [listTitleTextField release]; } else if (indexPath.row == 1) { cell.detailTextLabel.text = @"Pick an Icon"; cell.textLabel.text = @"List Icon"; } } else { cell.textLabel.text = @"Add Wish"; } return cell; ``` }