Wie setzen UITextfield-Breite dynamisch?
Ich habe die iPad-Anwendung.
Gibt es drei Fragen, die textfields
. Ich habe Breite UITextField
dynamisch text
kommt aus webservice. und ich habe UITextField
Breite gleiche wie Fragen text.
wenn Texte Frage klein ist, dann UITextField
klein ist,
wenn Texte Frage der Größe ist, groß ist, dann UITextField
groß ist,
Ich habe folgenden code.....
txtQuestionOne.hidden=NO;
txtQuestionTwo.hidden=NO;
txtQuestionThree.hidden=NO;
imgQueone.hidden=NO;
imgQueTwo.hidden=NO;
imgQueThree.hidden=NO;
[txtQuestionOne setPlaceholder:[[appDelegate.questions objectAtIndex:0] objectForKey:@"question"]];
appDelegate.FirstQues =[[appDelegate.questions objectAtIndex:0] objectForKey:@"question"];
NSLog(@"current q1 %@", [[appDelegate.questions objectAtIndex:0] objectForKey:@"question"]);
if ([[[appDelegate.questions objectAtIndex:0] objectForKey:@"permission"] isEqualToString:@"1"]) {
ratingButton1.hidden=NO;
ratingLabel1.hidden=NO;
}
[txtQuestionTwo setPlaceholder:[[appDelegate.questions objectAtIndex:1] objectForKey:@"question"]];
appDelegate.SecondQues =[[appDelegate.questions objectAtIndex:1] objectForKey:@"question"];
NSLog(@"current q2 %@", [[appDelegate.questions objectAtIndex:1] objectForKey:@"question"]);
if ([[[appDelegate.questions objectAtIndex:1] objectForKey:@"permission"] isEqualToString:@"1"]) {
ratingButton2.hidden=NO;
ratingLabel2.hidden=NO;
}
[txtQuestionThree setPlaceholder:[[appDelegate.questions objectAtIndex:2] objectForKey:@"question"]];
appDelegate.ThridQues =[[appDelegate.questions objectAtIndex:2] objectForKey:@"question"];
NSLog(@"current q3 %@", [[appDelegate.questions objectAtIndex:2] objectForKey:@"question"]);
if ([[[appDelegate.questions objectAtIndex:2] objectForKey:@"permission"] isEqualToString:@"1"]) {
ratingButton3.hidden=NO;
ratingLabel3.hidden=NO;
}
Bitte helfen Sie mir, ich weiß nicht, was kann ich tun?
- Warum nutzen Sie nicht
UILabel
statt ?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Verwenden Sie diese Option, um die Größe für ein NSString der angegebenen schriftart. Und die zurückgegebenen CGSize Größe der UI-element-label, textfield.
ZB:
haben Sie versucht, diese
Haben Sie einen Blick auf diese post
Zeigt es Ihnen die Nutzung von
sizeWithFont
die Ihnen eine CGSize Objekt von der Größe Ihres Textes. Dann Bearbeiten Sie Ihre Felder mit Sternchen-frame mit den Daten dieses CGSize Objekt.