iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 8
0
Mobile Development

IOS 基本元件運用和套件運用系列 第 8

(Day8)第三方套件IQKeyboardManager

在做專案時有時會遇到鍵盤擋著輸入框看不到當前輸入了什麼的情況。現在我要用的套件就能解決這種狀況。
https://ithelp.ithome.com.tw/upload/images/20200916/20129678728ciQe6rX.pnghttps://ithelp.ithome.com.tw/upload/images/20200916/20129678KvDGpp4QvI.png

安裝套件

先用Cocoapods 安裝套件。在podfile中加入這一段。

pod 'IQKeyboardManagerSwift'

使用方法

在 AppDelegate.swift , import IQKeyboardManagera framework 開啟 IQkeyboardManager.

import IQKeyboardManagerSwift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

      IQKeyboardManager.shared.enable = true

      return true
    }
}

這下叫出鍵盤後輸入框就會自動往上移了。
https://ithelp.ithome.com.tw/upload/images/20200921/20129678fW78cPsK4q.png


上一篇
(Day7)在App增加Google Sign In 功能
下一篇
(Day9)IQKeyboardManager功能
系列文
IOS 基本元件運用和套件運用30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言