2024-11-29
防止键盘挡掉页面的内容
在第一个function下面添加以下代码:
IQKeyboardManager.shared.isEnabled = true
示例代码:
注意以下代码整合了firebase和IQKeyboardManager。
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//设置http代理,firebase不支持socks5代理
setenv("grpc_proxy", "http://127.0.0.1:1087", 1)
FirebaseApp.configure()
let db = Firestore.firestore()
print(db) //测试是否成功,要出现<FIRFirestore: 0x600002129c70>字样
IQKeyboardManager.shared.isEnabled = true
return true
}
done
的标签。IQKeyboardManager.shared.enableAutoToolbar = true
注意,以上办法已经废弃,应该这样使用:
import IQKeyboardToolbarManager
IQKeyboardToolbarManager.shared.isEnabled = true
IQKeyboardManager.shared.resignOnTouchOutside = true