【发布时间】:2015-12-13 09:35:12
【问题描述】:
我正在使用 Swift 编写自定义键盘。我在制作返回按钮时遇到了一些问题。返回按钮应根据用户正在编写的文本字段更改标题“返回”、“完成”和“搜索”。
为此,我是这样写的。
// 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)
}
我这样做对吗?
我可以做按钮添加段落,但是当按钮标题为“完成”时我不知道如何隐藏键盘,也不知道当按钮标题为“搜索”时如何设置搜索功能。
请大家帮帮我。
【问题讨论】:
-
您是否尝试将键盘从您的视图中移除?
标签: ios swift custom-keyboard