2017-04-17 44 views
-1

無論何時點擊文本字段,我都會遇到錯誤。我無法理解這個意思。這發生在我嘗試在用戶點擊一個textfieldfield時加載viewController。這裏點擊UITextField時的運行時錯誤

attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) ->() to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) ->()]> of generic specialization <preserving fragile attribute,()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A 
-> 0x102358014 <+120>: brk #0x1 

enter image description here

+0

你在點擊textField時想做什麼? – Sneha

+0

是self.location是UITextField類型? –

+0

你在使用故事板嗎? – JuicyFruit

回答

1

功能textFieldShouldBeginEditing

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { 
     if textField == self.location { 

      let vc = RquestDetailViewController() 

      self.show(vc, sender: nil) 
     } 
     return false 
} 

錯誤是用於編輯之前檢查先決條件。您錯過了視圖更改。這可能會導致文本字段委託流中出現一些內部運行時錯誤。

嘗試使用UIButtonUILabel & UITapGestureRecognizer來代替。

+0

sry我在textfield didbeginediting這樣做,但我設置文本字段的輸入視圖爲零。對我很好。我的猜測是textFieldShouldBeginEditing也不錯。 – hasan83

+0

這是你的選擇,但我不想使用你的代碼;) - 從調用者的角度來看它。我問你:「我可以輸入文字嗎?」而不是告訴我是或否,你爲我完成了一些完全意想不到的事情。 – ObjectAlchemist

+0

是真的。這可能是一個糟糕的用戶體驗。但從技術角度來看,它完全可以。 – hasan83