2014-03-03 29 views
0

我很困惑!,這不是我第一次創建自定義單元格,但是這次UILabel沒有出現我不知道問題在哪裏?沒有出現自定義單元格的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

我做了一個測試,以改變UILabel的背景顏色,它顯示背景顏色沒有文本! –

+0

標籤在哪裏 – meda

回答

1

改變這一行:

self.tweet_is.frame = CGRectMake(30, 30, 300.0f, 300.0f); 

設置self.tweet_is.frame = CGRectMake(30, 30, 300.0f, 30.0f);

如果你的單元格高度小於300(我認爲是),那麼你看不到文字。讓我知道如果這有助於.. :)

+0

太好了,謝謝你的幫助 –

相關問題