You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self rowHeightForRecord:nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
float cellWidth = self.tableView.frame.size.width;
// other controls
RTLabel *updateContentLabel;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DataCell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DataCell"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// other controls
updateContentLabel = [[RTLabel alloc] init];
updateContentLabel.tag = 1006;
updateContentLabel.backgroundColor = [UIColor redColor];
updateContentLabel.lineBreakMode = RTTextLineBreakModeWordWrapping;
updateContentLabel.lineSpacing = 20;
[cell.contentView addSubview:updateContentLabel];
} else {
// other controls
updateContentLabel = (RTLabel *)[cell viewWithTag:1006];
}
id record = [activityUpdateArray objectAtIndex:indexPath.row];
triggeredByAvtar.frame = CGRectMake(10, 10, 25, 25);
triggeredByAvtar.image = [[StarshipImagesServices shared] getImageWithUrl:[record objectForKey:@"TriggeredByProfileImage"]];
if ( triggeredByAvtar.image == nil ) {
triggeredByAvtar.image = [UIImage imageNamed:@"img-fetching.png"];
}
// other controls
updateContentLabel.frame = CGRectMake(10, 35, cellWidth-20, 300);
[self setUpdateContent:updateContentLabel forRecord:record];
CGSize optimumSize = [updateContentLabel optimumSize];
updateContentLabel.frame = CGRectMake(0, 0, cellWidth-20, 100); // set height 100 for temporary test
// other controls
return cell;
}
-(void)setUpdateContent:(RTLabel *)contentLabel forRecord:(id)record {
NSString *string1 = @"this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text";
NSString *string2 = @" black black black black black black ";
NSString *string3 = @"this is blue text this is blue text this is blue text this is blue text this is blue text";
![Screen Shot 2013-02-05 at 12 59 45 PM](https://f.cloud.github.com/assets/641959/126586/fe601028-6f65-11e2-8503-80343a40c282.png)
NSString *text = [NSString stringWithFormat:@"<font face='%@' size=12 color='#2E4AF7'>'%@'</font><font face='%@' size=12 color='#000000'> %@ </font><font face='%@' size=12 color='#2E4AF7'>%@</font>", FontRegular, string1, FontRegular, string2, FontRegular, string3];
contentLabel.text = text;
[contentLabel setParagraphReplacement:@""];
}
-(float)rowHeightForRecord:(id)record {
float cellWidth = self.tableView.frame.size.width;
NSString *string1 = @"this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text this is blue text";
NSString *string2 = @" black black black black black black ";
NSString *string3 = @"this is blue text this is blue text this is blue text this is blue text this is blue text";
NSString *text = [NSString stringWithFormat:@"<font face='%@' size=12 color='#2E4AF7'>'%@'</font><font face='%@' size=12 color='#000000'> %@ </font><font face='%@' size=12 color='#2E4AF7'>%@</font>", FontRegular, string1, FontRegular, string2, FontRegular, string3];
// FontRegular font defined globally, Optima in this case
RTLabel *rtLabel = [[RTLabel alloc] initWithFrame:CGRectMake(0, 0, cellWidth-20, 300)];
rtLabel.lineSpacing = 20.0;
[rtLabel setText:text];
CGSize optimumSize = [rtLabel optimumSize];
NSLog(@" / / / /%@/ / / / ", NSStringFromCGSize(optimumSize));
return optimumSize.height+60;
}
The text was updated successfully, but these errors were encountered:
Hi
there is issue in the RTLabel with its frame.
its height is not correct. Always shown only one line of text.
Log
updateContentLabel.frame : {{0, 0}, {300, 100}}
optimumSize of RTLabel : {296.856, 82}
The text was updated successfully, but these errors were encountered: