我尝试更改表格视图中单元格的 with ,我不做自定义单元格,我只是子类化 uitableviewcell 。
这是班级
@implementation customCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) {
CGRect nouveauframe = CGRectMake(0.0, 0.0, 44,44);
self.frame = nouveauframe;
}
return self;
}
-(void)dealloc
{
[super dealloc];
}
@end
这是我在 cellForRowAtIndexPath 中创建单元格时的情况:
static NSString *CellIdentifier = @"customCell";
customCell *cell = (customCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[customCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
[[cell textLabel]setText:[[[[Mission singletonMission] getObjectDataHistoireEncours] objectAtIndex:indexPath.row] valueForKey:[[langue singletonLangue] valeurBalise: @"_nom_label"]]];
cell.detailTextLabel.text = [[[[Mission singletonMission] getObjectDataHistoireEncours] objectAtIndex:indexPath.row] valueForKey:[[langue singletonLangue] valeurBalise: @"_valeur"]];
cell.userInteractionEnabled = FALSE;
retour = [cell retain];
但我的单元格的宽度没有改变,为什么?
当表格视图添加到表格视图时,表格视图会更改单元格的框架。如果要更改单元格的宽度,您应该更改表格的宽度,或更改单元格中 contentView 的宽度。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)