我是 ios 新手,我在 iqkeyboardmanager 上工作,我想在 IQKeyboardManager 中访问完成按钮操作。
问问题
20402 次
6 回答
38
您可以处理完成、下一个和上一个按钮的点击
[textField.keyboardToolbar.previousBarButton setTarget:self action:@selector(previousAction:)];
[textField.keyboardToolbar.nextBarButton setTarget:self action:@selector(nextAction:)];
[textField.keyboardToolbar.doneBarButton setTarget:self action:@selector(doneAction:)];
迅速:
customField.keyboardToolbar.doneBarButton.setTarget(self, action: #selector(doneButtonClicked))
func doneButtonClicked(_ sender: Any) {
//your code when clicked on done
}
于 2018-01-10T10:17:22.367 回答
16
你可以使用 UITextViewDelegate
func textFieldDidEndEditing(_ textField: UITextField) {
}
于 2017-10-26T09:56:01.647 回答
15
你可以导入
import IQKeyboardManager
在所需文件中,然后
vc1Textfield.addDoneOnKeyboard(withTarget: self, action: #selector(doneButtonClicked))
这里 vc1Textfield 是我的文本字段,doneButtonClicked 定义如下:
@objc func doneButtonClicked(_ sender: Any) { }
希望对某人有所帮助!!!快乐的编码......
于 2018-08-29T07:34:21.427 回答
6
我将尝试以更方便的方式描述:
import IQKeyboardManagerSwift
class EditPostViewCell: UITableViewCell {
@IBOutlet weak var commentTextView: UITextView!
override func awakeFromNib() {
IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "Send Comment"
commentTextView.delegate = self
}
@objc func didPressOnDoneButton() {
commentTextView.resignFirstResponder()
sendComment()
}
}
extension EditPostViewCell: UITextViewDelegate {
public func textViewDidBeginEditing(_ textView: UITextView) {
let invocation = IQInvocation(self, #selector(didPressOnDoneButton))
textView.keyboardToolbar.doneBarButton.invocation = invocation
}
}
于 2018-08-06T05:31:52.517 回答
0
第一的:
import the IQKeyboardManager.h
然后:
[self.textField.keyboardToolbar.doneBarButton setTarget:self action:@selector(doneAction:)];
于 2019-12-18T08:42:11.207 回答
0
于 2019-12-20T07:57:26.917 回答