在viewDidLoad中创建UITextField
复制代码
相关方法
复制代码
-
textFieldDemo = [[UITextField alloc] initWithFrame:CGRectMake(0, 150, 130, 30)]; textFieldDemo.backgroundColor = [UIColor brownColor];
-
textFieldDemo.secureTextEntry = YES; textFieldDemo.keyboardType = UIKeyboardTypeURL;
-
//textFieldDemo.returnKeyType = YES; [textFieldDemo setPlaceholder:@"UserName"];
- //UIReturnKeySearch textFieldDemo.delegate = self; [self.view addSubview:textFieldDemo];
相关方法
-
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [textFieldDemo resignFirstResponder];
-
}- (void)textFieldDidEndEditing:(UITextField *)textField{ textFieldDemo = textField; [textField resignFirstResponder];
-
}//-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation//{
-
// return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
- //}- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{ return YES;}- (BOOL)textFieldShouldReturn:(UITextField *)textField{ return YES;}