我有一个按钮和一个文本字段。按钮位于textField下方。现在,当我单击按钮时,新文本字段应显示在第一个文本字段下方,并且还应更改按钮的框架。当我尝试这个时它第一次工作,但是当我第二次点击时,新的文本字段没有显示,按钮框也没有改变。帮助我解决这个问题。
我写的代码是:
<div class="product" >
<div class="product-item">
<div class="product-item-container">
<div class="product-item-show-scroll">
<div class="product-item__content">
<h3>Title</h3>
<div class="product-item__img">
<img src="#">
</div>
</div>
</div>
<div class="product-item-under-scroll">
<div class="btn__group">
<button class="quick-cart">Quick Cart</button>
</div>
</div>
</div>
<div class="product-item__bottom">
<p class="price">Price</p>
</div>
</div>
<div class="md-modal">
Modal content for product
</div>
</div>
答案 0 :(得分:0)
声明x并在@implementation ViewController块中 像
@implementation Viewcontroller
{
int x,y;
}
并将其他代码写为
-(void)onboardCertificatesAddBtnBtnTap
{
if (y =585, x=632) {
_boardCertificationField= [[UITextField alloc]initWithFrame:CGRectMake(5, y+50, self.scrollView.frame.size.width/2-25, 40)];
_boardCertificationField.font = [UIFont systemFontOfSize:17];
_boardCertificationField.borderStyle=UITextBorderStyleRoundedRect;
[_scrollView addSubview:_boardCertificationField];
_expDateField = [[UITextField alloc]initWithFrame:CGRectMake(220, y+50, self.scrollView.frame.size.width/2-40, 40)];
_expDateField .font = [UIFont systemFontOfSize:17];
_expDateField .borderStyle=UITextBorderStyleRoundedRect;
[_scrollView addSubview:_expDateField];
_boardCertificatesAddBtn.frame = CGRectMake(5, x+50, 20, 20);
[_boardCertificatesAddBtn setImage:[UIImage imageNamed:@"Add1.png"] forState:UIControlStateNormal];
[_scrollView addSubview:_boardCertificatesAddBtn];
[_boardCertificatesAddBtn addTarget:self action:@selector(onboardCertificatesAddBtnBtnTap) forControlEvents:UIControlEventTouchUpInside];
y=y+50;
x=x+50;
}
else {
_boardCertificationField= [[UITextField alloc]initWithFrame:CGRectMake(5, y+50, self.scrollView.frame.size.width/2-25, 40)];
_boardCertificationField.font = [UIFont systemFontOfSize:17];
_boardCertificationField.borderStyle=UITextBorderStyleRoundedRect;
[_scrollView addSubview:_boardCertificationField];
_expDateField = [[UITextField alloc]initWithFrame:CGRectMake(220, y+50, self.scrollView.frame.size.width/2-40, 40)];
_expDateField .font = [UIFont systemFontOfSize:17];
_expDateField .borderStyle=UITextBorderStyleRoundedRect;
[_scrollView addSubview:_expDateField];
_boardCertificatesAddBtn.frame = CGRectMake(5, x+50, 20, 20);
[_boardCertificatesAddBtn setImage:[UIImage imageNamed:@"Add1.png"] forState:UIControlStateNormal];
[_scrollView addSubview:_boardCertificatesAddBtn];
[_boardCertificatesAddBtn addTarget:self action:@selector(onboardCertificatesAddBtnBtnTap) forControlEvents:UIControlEventTouchUpInside];
y=y+50;
x=x+50;
}