我有一个UITextView
用于为文章添加评论。 UITextView
下面的UIButton
名为'添加另一个评论'。在点击此UIButton
时,必须创建另一个UITextView
,以便旧的UITextView
被推到新的UITextView
之下。我必须能够做到这一点,我想要多少次。
编辑:我的问题不在于创建{{1}},而是将旧文本视图推送到新文本视图下方。这应该是这样的:
a)在打开评论部分之前
b)打开评论部分后
答案 0 :(得分:0)
嗨John是的,你可以点击按钮后创建uitextfield,你必须编写代码,如下所示
- (IBAction)addText:(id)sender
{
CGRect textfieldFrame = CGRectMake(0.0, 0.0, 100.0, 30.0);
UITextField *textField = [[UITextField alloc] initWithFrame:textfieldFrame];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = @"enter text";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.delegate = self;
[self.view addSubview:textField];
}
答案 1 :(得分:0)
只需更改动态块
中旧文本视图的y位置即可[UIView animateWithDuration:1.0动画:^ {
// set center = btn.y + btn height + 0.5 * tetview height +如果你想要的话,按钮下面的任何空格
}];
我很怀疑 正在使用滚动视图?用户将如何看待之前的评论?如果文本高度大于textview的高度怎么办?