我已经使用Interface Builder(IB)在iPhone应用程序中创建了一个表视图。我的表格样式设置为分组,并在IB中显示。但是,无论何时构建和运行,它都会在模拟器中显示为普通样式。分组样式设置不能从IB生效,UITableView
我有另一个视图设置为分组,并没有遇到此问题。有没有人遇到过这个问题?
视图的其余部分不是以编程方式创建的,所以我想避免为此视图执行此操作。必须有一些我错过了。
唯一的tableView方法我在做很多的事情在在这里我引入一个文本框进入选定方阵的细胞处理方法:
- (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;
}
发布您的代码? – 2009-11-21 13:50:13
没有真正的任何编程代码要发布是问题,在IB中将Style设置为“分组”,然后只是执行常规tableview I/F方法来设置节名称并根据需要修改表格单元以显示值。 – 2009-11-21 14:16:48
你是否将这与UITabBarController结合使用? – JamesSugrue 2009-12-17 02:47:10