Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 按下回车键时,设置自委托以隐藏键盘时出现问题_Objective C - Fatal编程技术网

Objective c 按下回车键时,设置自委托以隐藏键盘时出现问题

Objective c 按下回车键时,设置自委托以隐藏键盘时出现问题,objective-c,Objective C,我试图将文本字段设置为代理,以便在按下回车键时隐藏键盘 [self.velocityTextField setDelegate:self]; 这是编译,但它给了我一个语义问题。正确的方法是什么 以下是隐藏键盘的方法: -(BOOL) textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; return YES; } 即使您实现了textfield shouldRetu

我试图将文本字段设置为代理,以便在按下回车键时隐藏键盘

[self.velocityTextField setDelegate:self];
这是编译,但它给了我一个语义问题。正确的方法是什么

以下是隐藏键盘的方法:

-(BOOL) textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];
    return YES;
}

即使您实现了
textfield shouldReturn
您的视图控制器(self)不是UITextField委托,也可以通过以下方式修改控制器定义:

@interface YourViewController : UIViewController <UITextFieldDelegate>
@end
@界面YourViewController:UIViewController
@结束

这就是为什么您会得到
发送不兼容类型“id”的'viewController*const\u strong'参数的原因。

语义问题是什么?@Cristik“发送”不兼容类型“id”的'viewController*const\u strong'参数“抱歉,不要添加它,我的意思是修改您已有的接口定义:)