Solved: iOS Keyboard Blocks Text Field

[ad_1]
Move Up The TextField When The Keyboard Blocks It
When you have a long form, sometimes the iOS virtual Keyboard slides up and hides the UITextField.

Unfortunately it’s up to the programmer to handle this case and animate or move the textfield out of the way.

In this video, you’ll learn how to find the height of the keyboard so that you can move the uitextfield (or any other control for that matter) above the keyboard.

The Xcode Project and Source Code for this video can be downloaded from here:

This video uses the latest and greatest from Apple (Xcode 8, Swift 3, iOS 10).

For more tutorials on how to build iPhone apps, make sure you subscribe and visit my site where you’ll find a community of like minded learners! Learning something new is always more fun with other people!

Website:

CodeWithChris is dedicated to teaching beginners and non-programmers all about building iOS apps. On the site, you’ll find a ton of free resources and tutorials to aid you on your journey to learn iOS development. Many people have successfully picked up Swift 3, Xcode 8 and app building from my course and materials!

Intro & Outro music
“Heartbreaker” by Jahzzar (


Posted

in

by

Tags:

Comments

6 responses to “Solved: iOS Keyboard Blocks Text Field”

  1. Taha Sönmez Avatar

    Incredible ! Thank you Chris !

  2. PETER MAVRONICOLAS Avatar

    How to Dismiss the Keyboard:

    let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.dismissKeyboard))
    self.view.addGestureRecognizer(tap)
    }
    //Calls this function when the tap is recognized.
    func dismissKeyboard() {
    //Causes the view (or one of its embedded text fields) to resign the first responder status.
    view.endEditing(true)

  3. John_M Avatar

    Great video chris!!
    I've tried to implement this on one of my projects, but i keep getting an error on this line

    let rect:CGRect = info["UIKeyboardFrameEndUserInfoKey"] as! CGRect

    error: Could not cast value type 'NSConcreteValue' to '__C.CGRect'

    I know this isn't part of your course to help me with but i would appreciate any tips from anyone on how to solve this issue
    Ive looked all over google and can't find help with this Error

  4. Slava Slutsker Avatar

    UIStackView is great except it needs minimum iOS version to be 9. So you app shouldn't work on device with iOS 8.
    Chris, what do think about this solution that solves the case you are talking about ?https://github.com/michaeltyson/TPKeyboardAvoiding

  5. lucas moraes Avatar

    Awesome video Chris !!

Leave a Reply

Your email address will not be published. Required fields are marked *