所以我用一個UIPickerView作爲一個的UITextField的第一個響應者。我設置爲顯示:的UITextField反應遲鈍打開UIPickerView
var myPickerView = UIPickerView()
myTextField.inputView = myPickerView
我是不是有這個問題,直到我添加了一個UITapGestureRecognizer(這將讓我點擊選擇器視圖之外開除吧)認爲,像這樣:
let dismissUnitPickerGesture = UITapGestureRecognizer(target: self, action: "hidePicker")
dismissUnitPickerGesture.delegate = self
dismissUnitPickerGesture.cancelsTouchesInView = false
hidePicker FUNC:
@IBAction func hidePicker(){
myTextField.resignFirstResponder()
//I don't think this code is relevant to the problem, but I included it just in case
if materialSelectedOption == "Aluminum Cans" {
amountTextField.placeholder = "Number of Cans"
unitCell.hidden = true
}
}
現在它佔用的的UITextField 5次點擊模擬器上打開選擇器視圖,這是令人沮喪的,顯然不利於一個AP頁。我很確定它與輕擊手勢有關,但我可能是錯的。
如果您還有其他任何問題,請讓我知道。
對不起,我的無知,但可以幫助指出我將如何實現這一點?我以前沒有使用過任何類型的東西。 –
將其粘貼到您的viewController中! –
好吧,我想,和禁用UITapGestureRecognizer的東西,但現在並沒有消除,當我點擊它的外面,這是我需要 –