I am writing a custom keyboard with Swift. I am facing some problems in making return button. The return button should change title "Return", "Done" and "Search" according to textField that user is writing.
To do it, I write like this.
// Syntax are not correct. I just want to explain my idea.
override fun viewDidLoad()
{
super.viewDidLoad()
if ((textDocumentProxy as UIKeyInput).returnKeyType == .Default)
{
btnReturn.addTarget("addParagraph", .TouchUpInside)
btnReturn.setTitleLabel("Return", .Normal)
}
else if ((textDocumentProxy as UIKeyInput).returnKeyType == .Done)
{
btnReturn.addTarget("DoneKey", .TouchUpInside)
btnReturn.setTitleLabel("Done", .Normal)
}
else if ((textDocumentProxy as UIKeyInput).returnKeyType == .Search)
{
btnReturn.addTarget("searchKey", .TouchUpInside)
btnReturn.setTitleLabel("Search", .Normal)
}
Am I doing this correctly?
I can do the button to add paragraph but I don't know how to hide the keyboard when the button title is "Done" and don't know how to make search function when the button title is "Search".
Anyone please help me.