iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 16
0
Software Development

30 天上手 iOS App 開發系列 第 24

30 天上手 iOS App 開發 Day 25

使用手機很常需要輸入文字,這時候虛擬鍵盤就會從螢幕底部升上來,因而擋住部分介面。因為 iOS 並沒有自動調整介面,於是我們開發者每次就得自行處理,因為太常需要用到,有許多地方必須寫收起鍵盤,且容易出問題,於是就有了高人寫的開源第三方套件IQKeyboardManager!

首先在 Podfile 中加入

pod 'IQKeyboardManagerSwift'

接著將套件安裝在專案中

pod install

在 AppDelegate.swift 中 enable&import IQKeyboardManagerSwift

import IQKeyboardManagerSwift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

  IQKeyboardManager.sharedManager().enable = true

  return true
}

}

呈現效果如下


上一篇
30 天上手 iOS App 開發 Day 24
下一篇
30 天上手 iOS App 開發 DAY 26
系列文
30 天上手 iOS App 開發28
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言