-(void)touchesBegan:(NSSet )touches withEvent:(UIEvent )event
{
//宣告一个UITouch的指标来存放事件触发时所撷取到的状态
UITouch *touch = [[event allTouches] anyObject];
CGFloat ly = [touch locationInView: self.remarkTextView].y;
if ( ly < 0 || ly > viewHeight(self.remarkTextView) ) { //点标题栏也会消失,点其他地方捕捉不到了
[self.remarkTextView resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
本文介绍了一个iOS应用中处理触控事件的具体实现方法。通过UITouch获取触控位置,并判断是否在TextView范围内来决定是否取消输入焦点。此方法有助于更好地控制用户交互行为。
38

被折叠的 条评论
为什么被折叠?



