在ipad中隐藏键盘

时间:2011-08-13 20:39:17

标签: iphone objective-c ipad

点击UIImageView时如何隐藏键盘?

我正在尝试使用此功能,但它不适用于UIImageView:

- (IBAction)backgroundTap:(id)sender 
{

logLang.hidden=YES;
pasComp.hidden=YES; 
[login resignFirstResponder];
[password resignFirstResponder];


}

1 个答案:

答案 0 :(得分:1)

确保您的图片在xib中启用 user interaction ?如果您要以语法方式添加imageView,那么

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

        UITouch *touch = [touches anyObject];

        if ([touch view] == yourImageView) {
             logLang.hidden=YES;
             pasComp.hidden=YES; 
             [login resignFirstResponder];
             [password resignFirstResponder];
        }
 }

使用UIResponder方法touchesBegan,touchesMoved,touchesEnded等来检测图像视图上的触摸