要將的UILabel添加到表格單元格我- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
使用像素化的UILabel表格單元格
UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(270, 10, 40, 12)];
timeLabel.text = @"2s";
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.font = [UIFont systemFontOfSize:12];
timeLabel.textColor = [UIColor lightGrayColor];
timeLabel.highlightedTextColor = [UIColor whiteColor];
timeLabel.textAlignment = UITextAlignmentRight;
timeLabel.frame = CGRectIntegral(timeLabel.frame);
[cell.contentView addSubview:timeLabel];
。
這工作正常,直到我滾動表或選擇一個單元格。然後標籤變成像素化。
在負載:
行動後:
我也試圖通過繼承的UITableViewCell添加標籤,並加載它在 - (void) layoutSubviews
。
編輯:它不可能使用標準單元格標籤,因爲它們已被使用。我需要添加一個額外的標籤。
你在什麼版本的iOS?如果它是6.x,它可能是軟件中的一個錯誤(如果你不是5.x,它甚至可能是一個錯誤......沒有人是完美的)。是否有可能使背景不透明? – FeifanZ 2012-08-12 12:52:44
我在iOS 5.1.1和iOS 6b4上測試了它。我無法想象這是一個錯誤,因爲包括Facebook和Twitter在內的許多應用程序都將UILabels添加到表格單元格中。 – 2012-08-12 13:00:12
是的,有可能使背景不透明,但這並不能解決問題。 – 2012-08-12 13:18:10