向 TableViewCell 中的 UITextField 的 return 键添加操作
Add action to return key for UITextField inside a TableViewCell
我阅读了很多教程来为 UITextField
中键盘上的 return 键添加动作,但是其中 none 帮助我在 UITextField
时添加动作TableViewCell
里面。我应该在 Cell class
中还是在 cellForRowAt
函数中管理它?你能帮我吗?
您应该将一个 UITextFieldDelgate 添加到您的 UITextField 中,您可以在其中覆盖函数 textFieldShouldReturn,您可以在其中对 return 键执行操作。
查看此以供参考。 https://developer.apple.com/documentation/uikit/uitextfielddelegate/1619603-textfieldshouldreturn
我阅读了很多教程来为 UITextField
中键盘上的 return 键添加动作,但是其中 none 帮助我在 UITextField
时添加动作TableViewCell
里面。我应该在 Cell class
中还是在 cellForRowAt
函数中管理它?你能帮我吗?
您应该将一个 UITextFieldDelgate 添加到您的 UITextField 中,您可以在其中覆盖函数 textFieldShouldReturn,您可以在其中对 return 键执行操作。
查看此以供参考。 https://developer.apple.com/documentation/uikit/uitextfielddelegate/1619603-textfieldshouldreturn