應該raise.in選擇器視圖我又增加了這樣在文本框點擊pickerview改變文本框輸入視圖從pickerview到鍵盤在SWIFT 3.0
picker.delegate = self
picker.dataSource = self
picker.showsSelectionIndicator = true
let toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
toolBar.tintColor = UIColor.black
//UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1)
toolBar.sizeToFit()
let addbutton = UIBarButtonItem(title: "+Add", style: UIBarButtonItemStyle.plain, target: self, action: #selector(GBEDasboardViewController.addproducts))
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: #selector(GBEDasboardViewController.addproducts))
toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
toolBar.isUserInteractionEnabled = true
productname.inputView = picker
productname.inputAccessoryView = toolBar
上點擊Add按鈕pickerview工具應該關閉和鍵盤應提高
func addproducts(){
self.view.endEditing(true)
}
pickerview正在關閉,但如何提高鍵盤。
你想在同一個文本框的鍵盤和選擇器? –
是初始選擇器視圖點擊添加選擇器視圖然後我應該得到鍵盤爲同一個文本框 –