J'ai une longue chaîne de caractères (y compris \n
caractères de nouvelle ligne) que je nourris dans un UILabel
pour l'affichage. Le UILabel
est configuré dynamiquement pour fournir suffisamment d'espace pour le texte.Le texte UILabel ne contient pas de mot-clé
Mon code ressemble à ceci:
myText = [NSString stringWithFormat:@"%@some text: %@ \n \n %@", myText, moreText1, moreText2];
NSLog(@"%@", myText);
myLabelSize = [vLabelText sizeWithFont:[UIFont fontWithName:@"Helvetica" size:(15.0)] constrainedToSize:cMaxLabelSize lineBreakMode:UILineBreakModeWordWrap];
UILabel *lBody = [[UILabel alloc] initWithFrame:CGRectMake(cFromLeft, vFromTop, vLabelSize.width, vLabelSize.height)];
lBody.font = [UIFont fontWithName:@"Helvetica" size:(15.0)];
lBody.lineBreakMode = UILineBreakModeWordWrap;
lBody.textAlignment = UITextAlignmentLeft;
lBody.backgroundColor = [UIColor cyanColor];
[myScrollView addSubview:lBody];
lBody.text = vLabelText;
Mon problème est que le texte ne revient pas, mais tronque après la première ligne. Les nouvelles lignes \n
sont ignorées.
Pousse .. tu me bats à J'ai eu ce problème et je savais quand j'ai lu votre titre que j'avais votre solution. –
Ici, avoir un upvote. :) – mtmurdock
Ici, avoir un cookie. : O – Sandy