Что такое хороший способ убрать эту клавиатуру, когда пользователь прикасается к ней? Я пробовал использовать метод прикосновения, но это не работает. Однако метод textfieldshouldreturn работает нормально. Я не могу думать о других способах этого. Может кто-то, пожалуйста, помогите мне здесь, я бы очень признателен за любую помощь. БлагодаряКак убрать клавиатуру iOS на вид таблицы
import UIKit
var courseCatalog : [String] = Array<String>()
class HomeViewController: UIViewController, UITextFieldDelegate , UITableViewDelegate{
@IBOutlet var searchTextField: UITextField!
override func viewDidLoad() {
courseCatalog = ["Accounting", "Administration" , "American Studies" , "Anthropology" , "Arabic" , "Art" , "Aerospace Studies" , "American Sign Language" , "Biology" , "Child Development" , "Chemistry" , "Chinese" , "Criminal Justice", "Communication Studies" , "Computer Science", "Computer Engineering"]
super.viewDidLoad()
println(PFUser.currentUser())
println("Home Tab View Controller")
searchTextField.delegate = self
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return courseCatalog.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
cell.textLabel?.text = courseCatalog[indexPath.row]
return cell
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
self.searchTextField.resignFirstResponder()
}
func textFieldShouldReturn(textField: UITextField!) -> Bool {
searchTextField.resignFirstResponder()
return true
}
}
Возможный дубликат [скрыть клавиатуру для текстового поля в быстром языке программирования] (http://stackoverflow.com/questions/24908966/hide-keyboard-for-text-field-in-swift-programming-language) – Almo