我已經添加文本框動態地如下滾動型: -設置最大長度,以動態地添加文本框
for(int i = 0; i< responseBillPay.billerDetails.payeeFormat.count; i++) {
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, y, width, height)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = [responseBillPay.billerDetails.payeeFormat[i] name];
textField.delegate = self;
[innerScroll addSubview:textField];
}
現在我想設置最大長度每個textfield.How我能做到這一點? 我作爲web服務的響應: -
payeeFormat =
(
{
displayFlag = false;
length = 4;
name = "BU(Billing Unit)";
validation = "Please enter 4 digits BU(Billing Unit)";
},
{
displayFlag = false;
length = 2;
name = "PC(Processing Cycle)";
validation = "Please enter only numbers in PC(Processing Cycle),PC(Processing Cycle) should be maximum 2 digits,PC(Processing Cycle) should be minimum 1 digit";
},
{
displayFlag = true;
length = 12;
name = "Consumer No.";
validation = "Consumer No. should be maximum 12 digits,Consumer No. should be minimum";
}
);
請參閱https://stackoverflow.com/questions/433337/set-the-maximum-character-length-of-a-uitextfield?rq=1。 – Daniel