0
我希望我的標籤略微分開,並且有多行文本可用。UITableViewCell標籤的顯示不正確
Cell.m是
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(1,1,69,69);
float limgW = self.imageView.image.size.width;
if(limgW > 0) {
self.textLabel.frame = CGRectMake(74,self.textLabel.frame.origin.y,self.textLabel.frame.size.width,self.textLabel.frame.size.height);
self.detailTextLabel.frame = CGRectMake(74,self.detailTextLabel.frame.origin.y+self.textLabel.frame.size.height,self.detailTextLabel.frame.size.width,self.detailTextLabel.frame.size.height);
}
}
在控制器中,cellForRowAtIndexPath
是:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
static NSString *CellIdentifier = @"Cell";
Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell to show todo item with a priority at the bottom
cell.textLabel.text = object[@"Title"];
cell.detailTextLabel.text = object[@"Request"];
PFFile *thumbnail = object[@"ProfilePic"];
cell.imageView.image = [UIImage imageNamed:@"[email protected]"];
cell.imageView.file = thumbnail;
CALayer * l = [cell.imageView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:36.7];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor whiteColor] CGColor]];
UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:15];
UIFont *cellFont2 = [UIFont fontWithName:@"Verdana-Bold" size:12];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.numberOfLines = 0;
cell.textLabel.font = cellFont;
cell.detailTextLabel.font = cellFont2;
cell.textLabel.textColor = [UIColor whiteColor];
cell.detailTextLabel.textColor = [UIColor whiteColor];
cell.backgroundColor = [UIColor blackColor];
return cell;
}
怎麼會2號線是越來越縮寫,爲什麼是textLabel
和detailTextLabel
如此接近?
使用自定義標籤** cell.detailTextLabel ** –
看起來你想要一個真正自定義的單元格(你似乎已經在'Cell'中創建),但你仍然試圖獲得標準控件('textLa bel'和'detailTextLabel')來適合你的數據。相反,我建議對待你的新單元類,就好像你沒有訪問任何控件,只是自己創建你需要的單元。 – mbm29414