IQKeyboardManager 与 CustomTextField (SkyFloatingLabelTextField) 使用 Swift 3
Posted
技术标签:
【中文标题】IQKeyboardManager 与 CustomTextField (SkyFloatingLabelTextField) 使用 Swift 3【英文标题】:IQKeyboardManager with CustomTextField (SkyFloatingLabelTextField) using Swift 3 【发布时间】:2016-12-01 08:10:02 【问题描述】:我正在使用SkyFloatingLabelTextField
,这是一个自定义UITextField
。将IQKeyboardManager
添加到我的 Podfile (pod install
) 后,预计它将自动处理键盘问题。
有任何将IQKeyboardManager
与customTextfield
整合在一起的线索吗?
【问题讨论】:
你为那个 VC 启用了 iqkeyboard manager 吗? 我之前没用过SkyFloatingLabelTextField
,但是你启用IQKeyboardManager
了吗?
已经启用了IQKeyboardManage
r,我将two textfield
放在uiview 中,iPad 横向,keyboard
在点击first textfield
时覆盖了uitextfield。自定义uitextfield有什么办法吗?
【参考方案1】:
SWIFT 3.0+ 解决方案
在 AppDelegate 中:
// Enable IQKeyboardManager for customization
IQKeyboardManager.sharedManager().enable = true
在 UIViewController 中
class A : UIViewController
viewDidLoad()
customizeKeyboard()
func customizeKeyboard()
IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true
IQKeyboardManager.sharedManager().shouldShowTextFieldPlaceholder = false
IQKeyboardManager.sharedManager().toolbarDoneBarButtonItemText = ""
IQKeyboardManager.sharedManager().shouldHidePreviousNext = true
IQKeyboardManager.sharedManager().keyboardDistanceFromTextField = 150
emailTextField.delegate = self
passwordTextField.delegate = self
// to remove the autocorrect on top of keyboard
emailTextField.autocorrectionType = .no
emailTextField.keyboardType = .emailAddress
// to remove the IQManager view on top of Keyboard
let emptyUIView = UIView()
emailTextField.inputAccessoryView = emptyUIView
passwordTextField.inputAccessoryView = emptyUIView
forgotEmailTextField.inputAccessoryView = emptyUIView
【讨论】:
以上是关于IQKeyboardManager 与 CustomTextField (SkyFloatingLabelTextField) 使用 Swift 3的主要内容,如果未能解决你的问题,请参考以下文章
IQKeyboardManager 与 CustomTextField (SkyFloatingLabelTextField) 使用 Swift 3
尝试将 IQKeyboardManager 与 Xcode 和 Swift 一起使用时出错
集成 IQKeyboardManager 时找不到 .h 文件