How to add multiple UITextfield in iOS 5?
问题 How do I create and add multiple UITextField to my controller? I can create one, like this: UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(5,5,100,25)]; tf.borderStyle = UITextBorderStyleRoundedRect; [tf setReturnKeyType:UIReturnKeyDefault]; [tf setEnablesReturnKeyAutomatically:YES]; [tf setDelegate:self]; [self.view addSubview:tf] But do I need to do that for each UITextField? Whats the best approach to template UI Controls? 回答1: Put it in a loop, offset each text field's Y