resignFirstResponder预期标识符

时间:2016-11-05 10:14:47

标签: ios objective-c iphone

如果用户按下返回键,我想隐藏键盘! 这里.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;
}

但是错误说:期望的标识符,这段代码出了什么问题?

2 个答案:

答案 0 :(得分:1)

删除点:

[self.testItHere resignFirstResponder];

答案 1 :(得分:-2)

删除点,并在按下返回键时调用textFieldShouldReturn隐藏键盘。

-(BOOL)textFieldShouldReturn:(UITextField *)textField
 {
     [self.testItHere resignFirstResponder];
     return YES;
 }