申し訳ありませんが、非常に基本的な初心者の質問です。UITextFieldとUITextViewがあるとします。次に、これらのTextField/Viewの上に透明なUIViewが配置されていることを想像してください。タッチすると応答しません。cocoa-touch:どのオブジェクトに触れたか調べる方法
UIViewを(スワイプやピンチなどとは対照的に)タッチすると、ユーザーが触れる(TextFieldまたはView)どんなものでも最初のレスポンダになります。次のようなコマンドがありますか:
[objectThatWasTouched becomeFirstResponder];
?
私は以下の方法でこれを必要とします。今UITextViewがファーストレスポンダになるように、それが設定されているが、私はファーストレスポンダになるためにタッチするどんなオブジェクトたい:私はを取り除くために方法のいくつかの種類に必要になり、最終的には
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x); // will always be positive
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y); // will always be positive
if (deltaY == 0 && deltaX == 0) {
[self.view bringSubviewToFront:aSwipeTextView];
[self.view bringSubviewToFront:noteTitle];
[self.view bringSubviewToFront:doneEdit];
[aSwipeTextView becomeFirstResponder];
}
}
そして、最初のレスポンダ、すなわち最初のレスポンダに依存します。 UITextViewがタッチされた場合にのみ、firstresponderを取り除くれます:
- (IBAction)hideKeyboard
{
[aSwipeTextView resignFirstResponder];
[self.view bringSubviewToFront:canTouchMe];
}
感謝します。私は実際に関連する質問を投稿しました:http://stackoverflow.com/questions/7597909/defining-maximum-variance-of-an-uitextview –