touchsメソッドがありますが、ビューの一部の領域をクリックした場合にのみ機能します。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];// this will do the trick
}
どうすれば問題を解決できますか?
ありがとう
touchsメソッドがありますが、ビューの一部の領域をクリックした場合にのみ機能します。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];// this will do the trick
}
どうすれば問題を解決できますか?
ありがとう
これを試して
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[self.view addGestureRecognizer:singleTap];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
{
//Get touch point
CGPoint touchPoint=[gesture locationInView:self.view];
//Hide keyBoard
[self.view endEditing:YES];
}
OK、以下のコードを試して確認してください:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
[touch locationInView:self.view];
[self.view endEditing:YES];
}