嘗試使用工具欄
override func viewDidAppear(animated: Bool) {
...
var toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.Default
toolBar.translucent = true
toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1)
var nextButton = UIBarButtonItem(title: "Next", style: UIBarButtonItemStyle.Done, target: self, action: "nextTextfield")
var previousButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Plain, target: self, action: "previousTextfield")
var spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
toolBar.setItems([previousButton, spaceButton, nextButton], animated: false)
toolBar.userInteractionEnabled = true
toolBar.sizeToFit()
textField.delegate = self
textField.inputAccessoryView = toolBar
}
func nextTextfield() {
nextTextField.resignFirstResponder()
}
func previousTextfield() {
//if exist previous
//previousTextField.resignFirstResponder()
}
您正在鍵盤外添加手勢來解除它。 –
我用過,但由於某些原因我不wana使用手勢。因爲當我使用手勢時會禁用某些功能。 – Sahil
請刪除「返回false」並嘗試。 –