如果用户按下返回键,我想隐藏键盘! 这里.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextFieldDelegate>;
@property (weak, nonatomic) IBOutlet UITextField *testItHere;
@end
和.m
@implementation ViewController
@synthesize testItHere;
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;
{
[self.testItHere.resignFirstResponder]
return YES
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self updateTestKeyboard:self.interfaceOrientation];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.testItHere.delegate=self;
}
但是错误说:期望的标识符,这段代码出了什么问题?
答案 0 :(得分:1)
删除点:
[self.testItHere resignFirstResponder];
答案 1 :(得分:-2)
删除点,并在按下返回键时调用textFieldShouldReturn
隐藏键盘。
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.testItHere resignFirstResponder];
return YES;
}