Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 一个文本字段到其他6个文本字段_Ios_Storyboard_Textfield - Fatal编程技术网

Ios 一个文本字段到其他6个文本字段

Ios 一个文本字段到其他6个文本字段,ios,storyboard,textfield,Ios,Storyboard,Textfield,我希望是一个简短的问题 我有一个UITextfield,我想输入一个数字,并将该数字填充到同一VC上的其他6个UITextfields中 第一个文本字段被称为百分比目标,而其他文本字段被命名为endmonth1year1percentage,endmonth2year1percentage,endmonth3year1percentage,等等 我目前正在将iOS6与storey board一起使用 感谢您的帮助。谢谢。像这样试试 - (BOOL)textField:(UITextField *

我希望是一个简短的问题

我有一个
UITextfield
,我想输入一个数字,并将该数字填充到同一VC上的其他6个
UITextfield
s中

第一个文本字段被称为
百分比目标
,而其他文本字段被命名为
endmonth1year1percentage
endmonth2year1percentage
endmonth3year1percentage
,等等

我目前正在将iOS6与storey board一起使用

感谢您的帮助。谢谢。

像这样试试

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
//replace your textfield names here
textField1.text=textField.text;
textField2.text=textField.text;
textField3.text=textField.text;
textField4.text=textField.text;
textField5.text=textField.text;


return YES;
}

检测第一个文本字段中的更改:


然后更新要填充的其他文本字段的文本属性。

因此,对于第一个
UITextField
,必须将委托设置为负责显示文本字段的类(视图控制器或自定义视图)。对于另一个
uitextfield
s,您应该为每个uitextfield设置一个类似1,2,3..的标记(因为您说这将有很多
uitextfield

为第一个
UITextField
设置委托并设置标记后,可以实现两种不同的委托方法(取决于您想要的)

Sunny提供的方法,用于即时更改:

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  for(int i = firstTextViewTag; i<=lastTextViewTag; i++) {
    UITextView *newTextView = (UITextView *)[self.view viewWithTag:i]; 
    //or [yourCustomView viewWithTag:i]
    newTextView.text = textField.text;
  }

  return YES;
}
-(BOOL)textField:(UITextField*)textField应更改字符范围:(NSRange)范围替换字符串:(NSString*)字符串{

对于(int i=firstTextViewTag;i当你在一个文本字段中输入文本时,你想在所有文本字段中显示相同的数字,对吗?正确。我刚开始是6,但后来会以略高于100的数字结束,不想全部输入。好的,这现在比我高一点。我对这方面还是新手。你能用更简单的术语解释一下吗租赁
-(void)textFieldDidEndEditing:(UITextField *)textField {
  for(int i = firstTextViewTag; i<=lastTextViewTag; i++) {
      UITextView *newTextView = (UITextView *)[self.view viewWithTag:i]; 
      //or [yourCustomView viewWithTag:i]
      newTextView.text = textField.text;
  }
}