全部博文(8)
分类: 嵌入式
2010-12-11 13:38:25
UIControl *backGroundControl = [[UIControl alloc] initWithFrame:
CGRectMake(0, 0, 320, 480)];
backGroundControl.backgroundColor = [UIColor clearColor];
[backGroundControl addTarget:self
action:@selector(backgroundTab)
forControlEvents:UIControlEventTouchUpInside];
[window addSubview:backGroundControl];
- (void)backgroundTab
{
[field resignFirstResponder];
}
二、使用键盘上的Done键,这需要一个代理方法:
- (BOOL)textFieldShouldReturn:(UITextField *)textField;
键盘上没有Done键的时候,如何将return更改成Done:
field.returnKeyType = UIReturnKeyDone;
实 现:
field.delegate = self;
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[field resignFirstResponder];
return YES;
}