我很困惑!,这不是我第一次创建自定义单元格,但这次UILabel没有出现我不知道问题出在哪里?
这是自定义单元格Cell.m
mainView = [[UIView alloc] initWithFrame:CGRectZero];
mainView.backgroundColor = [UIColor colorWithRed:249.0/255.0 green:249.0/255.0 blue:249.0/255.0 alpha:1.0];
profile = [[UIImageView alloc] initWithFrame:CGRectZero];
profile.layer.masksToBounds = YES;
profile.layer.cornerRadius = 22.5;
profile.layer.borderColor = [UIColor whiteColor].CGColor;
profile.layer.borderWidth = 1.0f;
profile.clipsToBounds = YES;
tweet_is = [[UILabel alloc] initWithFrame:CGRectZero];
tweet_is.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:20];
tweet_is.backgroundColor = [UIColor clearColor];
tweet_is.textColor = [UIColor blackColor];
[self.mainView addSubview:tweet_is];
[self.mainView addSubview:profile];
[self.contentView addSubview:self.mainView];
-(void)layoutSubviews {
[super layoutSubviews];
self.mainView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 10.0f);
self.profile.frame = CGRectMake(15, 15, 45, 45);
self.tweet_is.frame = CGRectMake(30, 30, 300.0f, 300.0f);
}
这是tableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
Cell *cell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.tweet_is.text = @"Not approve";
return cell;
}
答案 0 :(得分:1)
更改此行:
self.tweet_is.frame = CGRectMake(30, 30, 300.0f, 300.0f);
设置self.tweet_is.frame = CGRectMake(30, 30, 300.0f, 30.0f);
如果你的细胞高度小于300(我认为是),那么你就看不到文字了。如果有帮助,请告诉我.. :)