iOSでは自前で実装する必要があります。
以下は、ScrollVIewを利用したサンプルです。
Keyboardが表示されたタイミングで、ScrollViewのcontentInsetとscrollIndicatorInsetsを変更します。
class AdjustScrollViewControll : NSObject{ var scrollView : UIScrollView? init(scrollView : UIScrollView){ self.scrollView = scrollView } func addObservers(){ let notificationCenter = NSNotificationCenter.defaultCenter() notificationCenter.addObserver(self, selector: #selector(self.willShowNotification(_:)), name: UIKeyboardWillShowNotification, object: nil) notificationCenter.addObserver(self, selector: #selector(self.willHideNotification(_:)), name: UIKeyboardWillHideNotification, object: nil) } func removeObserviers(){ NSNotificationCenter.defaultCenter().removeObserver(self) } func willShowNotification(notification: NSNotification) { let info = notification.userInfo let infoNSValue = info![UIKeyboardFrameEndUserInfoKey] as! NSValue let kbSize = infoNSValue.CGRectValue().size let contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height + 8, 0.0) scrollView!.contentInset = contentInsets scrollView!.scrollIndicatorInsets = contentInsets } func willHideNotification(notification: NSNotification) { let contentInsets = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0) scrollView!.contentInset = contentInsets scrollView!.scrollIndicatorInsets = contentInsets } }
ViewControllerからは次のようにコールします。
class HiddingKeyboardViewController: UIViewController,UITextFieldDelegate { @IBOutlet weak var scrollView: UIScrollView! var adjustTextFieldControll : AdjustScrollViewControll? override func viewDidLoad() { super.viewDidLoad() adjustTextFieldControll = AdjustScrollViewControll(scrollView: scrollView) } override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) adjustTextFieldControll!.addObservers() } override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) adjustTextFieldControll!.removeObserviers() } }