利用textField的代理和手势来进行取消第一响应的事件来提高用户体验!

来源:互联网 发布:mac l2tp服务器未响应 编辑:程序博客网 时间:2024/05/18 03:09
 在viewDidLoad中创建UITextField
  
  1. textFieldDemo = [[UITextField alloc] initWithFrame:CGRectMake(0, 150, 130, 30)]; textFieldDemo.backgroundColor = [UIColor brownColor];
  2.   textFieldDemo.secureTextEntry = YES; textFieldDemo.keyboardType = UIKeyboardTypeURL;
  3.   //textFieldDemo.returnKeyType = YES; [textFieldDemo setPlaceholder:@"UserName"];
  4.   //UIReturnKeySearch textFieldDemo.delegate = self; [self.view addSubview:textFieldDemo];
复制代码


  相关方法
 
  1.  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [textFieldDemo resignFirstResponder];
  2.   }- (void)textFieldDidEndEditing:(UITextField *)textField{ textFieldDemo = textField; [textField resignFirstResponder];
  3.   }//-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation//{
  4.   // return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  5.   //}- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{ return YES;}- (BOOL)textFieldShouldReturn:(UITextField *)textField{ return YES;}
复制代码
0 0
原创粉丝点击