1

实际上,当第一行广告默认值变大时,我正在尝试在下一行的文本字段中设置文本。你能帮我么。我的 uitextfield 是通过 IB 获取的。我正在尝试写它并想发表评论之类的东西。

[viewFeedback setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background_Feedback.png"]]];

CGSize size = [txtFeedback.text sizeWithFont:txtFeedback.font];
CGRect f = txtFeedback.frame;
f.size.height = ceil(size.width/f.size.width)*size.height;
txtFeedback.frame = f;

txtFeedback 是此处的文本字段名称..

4

1 回答 1

0

那么这将是一个增加UITextfield动态的高度。请按照此操作或添加您的自定义框架

在您的UITextViewDelegate实现中,textViewDidChange:您需要计算特定宽度的文本大小并进行相应调整。

-(void)textViewDidChange:(UITextView *)textView
{
    NSString *text = [textView text];
    NSFont *font = [textView font];
    CGFloat width = [textView frame].size.width;

    CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(width, 9999) lineBreakMode:UILineBreakModeWordWrap];

    /* Adjust text view width with "size.height" */
}
于 2013-08-05T05:33:32.317 回答