hopeanCom 发表于 2013-1-4 01:37:10

点击空白处取消UITextField第一响应

<div id="cnblogs_post_body">点击View的空白处UITextField取消第一响应
在学习的时候会遇到这个问题,点击空白处取消了UITextField的第一响应
http://www.hopean.com
更多阅读请访问http://www.hopean.com
相关代码如下:
在viewDidLoad中创建UITextField
textFieldDemo = [ initWithFrame:CGRectMake(0, 150, 130, 30)];    textFieldDemo.backgroundColor = ;    textFieldDemo.secureTextEntry = YES;    textFieldDemo.keyboardType = UIKeyboardTypeURL;    //textFieldDemo.returnKeyType = YES;    ;      //UIReturnKeySearch      textFieldDemo.delegate = self;    ;




相关方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    ;    }- (void)textFieldDidEndEditing:(UITextField *)textField{    textFieldDemo = textField;    ;}//-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation//{//    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);//}- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{    return YES;}- (BOOL)textFieldShouldReturn:(UITextField *)textField{    return YES;}
页: [1]
查看完整版本: 点击空白处取消UITextField第一响应