尝试在背景中隐藏数字键盘压力。 问题是Xcode 4没有找到如何在后台附加事件。
这是我的代码。
SecondViewController.h
- (IBAction)backgroundTouched:(id)sender;
SecondViewController.m
- (IBAction)backgroundTouched:(id)sender {
[self.view endEditing:YES];
}
答案 0 :(得分:1)
将主视图从UIView更改为UIControl,然后您就可以使用触摸事件作为背景。
答案 1 :(得分:0)
使用touchesBegan:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}