更改uitableviewcell的宽度 [英] change width of a uitableviewcell
本文介绍了更改uitableviewcell的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试更改表格视图中单元格的with,我不做自定义单元格,我只是将uitableviewcell子类化.
I try to change the with of a cell in a tableview, I don't do a custom cell, I just subclass 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中创建单元格时的情况:
and this is when I create my cell in the 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];
但是我的单元格的宽度没有变化,为什么?
but the width of my cell don't change, why?
推荐答案
表视图会在将单元格添加到表视图时更改其框架.如果要更改单元格的宽度,则应更改表格的宽度,或更改单元格中contentView的宽度.
Table views change the frame of cells when they are added to the table view. If you want to change the width of a cell, you should either change the width of the table, or change the width of the contentView in the cell.
这篇关于更改uitableviewcell的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文