2016-05-19 11 views

Antwort

0

können Sie die numberoflines Eigenschaft auf 0 setzen, um Multiline-Label zu erhalten. so etwas wie,

yourLabel.numberOfLines = 0; 

Sie Etikettenhöhe als je String etwas ändern kann, wie,

//Calculate the expected size based on the font and linebreak mode of your label 
// FLT_MAX here simply means no constraint in height 
CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX); 

CGSize expectedLabelSize = [yourString sizeWithFont:yourLabel.font constrainedToSize:maximumLabelSize lineBreakMode:yourLabel.lineBreakMode]; 

//adjust the label the the new height. 
CGRect newFrame = yourLabel.frame; 
newFrame.size.height = expectedLabelSize.height; 
yourLabel.frame = newFrame; 

Sie Höhe von Tableview Zeile durch die Implementierung Delegatmethode,

heightForRowAtIndexPath

Hoffnung erhöhen das wird helfen :)

+0

wie tabellaroom automatisch zu erweitern abhängig von label größe in swift 2.0 nur nicht objektiv-c.please schickte mich zu bald ... –

0

Zuerst UILab einstellen El Linie in 0 im Storyboard.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 

// need to calculte height of label text 
NSString *comment = [[self.objects objectAtIndex:[indexPath row]] objectForKey:@"Testo"]; 
    CGFloat whidt = 260; 
    UIFont *FONT = [UIFont systemFontOfSize:15]; 
    NSAttributedString *attributedText =[[NSAttributedString alloc] initWithString:comment attributes:@ { NSFontAttributeName: FONT }]; 
    CGRect rect = [attributedText boundingRectWithSize:(CGSize){whidt, MAXFLOAT} 
               options:NSStringDrawingUsesLineFragmentOrigin 
               context:nil]; 
    CGSize size = rect.size; 
    return size.height +130; 
} 

Breite ist die Etikettenbreite.