0

touchsメソッドがありますが、ビューの一部の領域をクリックした場合にのみ機能します。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];// this will do the trick
}

どうすれば問題を解決できますか?

ありがとう

4

2 に答える 2

0

これを試して

- (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];
}
于 2013-03-05T04:23:22.027 に答える
0

OK、以下のコードを試して確認してください:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    [touch locationInView:self.view];
    [self.view endEditing:YES];
}
于 2013-03-05T03:11:50.500 に答える