2016-12-14 4 views
0

私はautolayoutを扱うことができません、私はfacebook/instagramログインページと同様に実装する必要があります。つまり、入力フィールドのログインまたはパスワードをクリックすると、キーボードとすべての表現がウィンドウの新しいサイズに適応します。キーボードが表示された場合の表現の自動整列

enter image description here

キーボードの外観た後、それは次のようになります。自動レイアウトへ enter image description here

func updateBottomLayoutConstraintWithNotification(_ notification: Notification) { 
    let userInfo = notification.userInfo! 

    let animationDuration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue 
    let keyboardEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue 
    let convertedKeyboardEndFrame = view.convert(keyboardEndFrame, from: view.window) 
    let rawAnimationCurve = (notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).uint32Value << 16 
    let animationCurve = UIViewAnimationOptions.init(rawValue: UInt(rawAnimationCurve)) 

    bottomLayoutConstraint.constant = (view.bounds).maxY - convertedKeyboardEndFrame.minY 

    UIView.animate(withDuration: animationDuration, delay: 0.0, options: animationCurve, animations: { 
     self.view.layoutIfNeeded() 
    }, completion: nil) 
} 

答えて

0

ヒント:

  1. 使用scroll viewstatic table view
  2. スタティックテーブルビューを使用している場合は、すべてのスクロールおよびキーボード関連の処理がテーブルビューで処理されます。
  3. スクロールビューを使用すると、先頭の要素から最後まで制約が与えられ、thisライブラリを使用すると、非常に便利で使いやすいです。画像の下

感謝:) enter image description here

+0

実行し、それが実装されている方法を確認Instagramの少し何かを参照してください。入力フィールドをクリックすると、すべての要素が上に移動します。 – Feanon

関連する問題