Swift iOS How to update your view when keyboard appears

Sdílet
Vložit
  • čas přidán 13. 07. 2024
  • In this video I show you two ways to update your views based on the appearance of the UITextField keyboard.
    0:00 Intro
    1:36 How to detect the presence of the keyboard
    2:00 How to shift the entire view up
    3:22 How to adjust the view dynamically
    6:18 How to determine which element was tapped
    8:00 Converting coordinate system
    10:18 Apple's new keyboard layout guide
    13:10 Wrap up
    🤖 Source code
    github.com/jrasmusson/ios-pro...
     Articles
    developer.apple.com/design/hu...
    developer.apple.com/design/hu...
    developer.apple.com/documenta...
    developer.apple.com/documenta...
    🕹 Level up further with these awesome courses
    Professional iOS Development
    www.udemy.com/course/the-swif...
    Data Structures & Algorithms
    www.udemy.com/course/the-swif...
    Level Up in AutoLayout
    www.udemy.com/course/level-up...
    Level Up in Swift
    www.udemy.com/course/level-up...
  • Věda a technologie

Komentáře • 30

  • @zachdavis6624
    @zachdavis6624 Před rokem +2

    Makes great sense and thanks for providing, I really am mind blown that it has to be this complex though... Best explanation I've found though

  • @El_Butcher
    @El_Butcher Před rokem +1

    great tutorial with detailed explanation, thanks a lot, it was very useful for me

  • @santiagorodriguezaffonso2710

    Thanks for doing this! 💯

  • @teaberry73
    @teaberry73 Před 2 lety +3

    Great content and explanations! Thank you so much!

  • @romancebula1263
    @romancebula1263 Před 2 lety +1

    As always brilliant explanation!!

  • @swoleavocado
    @swoleavocado Před 2 lety

    Practical tip. Thank you Jonathan

  • @vamsi3877
    @vamsi3877 Před 2 lety

    Thanks Jonathan 👏

  • @xushnudkeldiboyev5393
    @xushnudkeldiboyev5393 Před 2 lety

    Nicely done ✅

  • @faikcoskuncakr7418
    @faikcoskuncakr7418 Před rokem

    You are perfect

  • @maestro2543
    @maestro2543 Před 2 lety

    You are genius 👍🏻

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety +1

      Thank you so much Roman. Glad you enjoyed the video.

  • @thiago_monteiro_
    @thiago_monteiro_ Před 2 lety

    Hey man. How are you? So, I really like your approach man. Do you give private lessons? Or like a mentoring? Take care man. Great videos always.

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety

      No private lessons at the moment Thiago. But I try to mentor those my videos and courses. Much cheaper than hiring me privately. Feel free to ask me any question though. Cheers - Jonathan

  • @wordpressmagics2613
    @wordpressmagics2613 Před rokem

    Hello! Thank you for the tutorial. I wanted to ask about the state when textFieldBottomY does not overlapped by keyboardTopY but at the same time keyboard is overlapping the UIButton that we need to press when text was entered. Would it also work? Thanks.

  • @odiadavid6957
    @odiadavid6957 Před rokem

    ❤❤

  • @rungxanh2901
    @rungxanh2901 Před rokem +1

    Thank you so much Jonathan! This is the only tutorial that's gone the programmatic way, just what I needed 🫡

  • @perplisheye
    @perplisheye Před 11 měsíci

    03:10 scroll up textfield

  • @fish330
    @fish330 Před 8 měsíci

    Day Jonathon, great explanation. I see that the comments are a year old and the IOS changes regularly. When I type in your nuanced boolean solution for checking whether to raise the view or not - I get an error from this line of code - let currentTextField = UIResponder.currentFirst() as? UITextField else {return}
    The error message is - Type 'UIResponder' has no member 'currentFirst'. Can you please help me on this? Cheers n beers

  • @SamacInnes
    @SamacInnes Před 2 lety

    This seems to work only if you select the textbox once, if you dismiss the keyboard and then select the text field again it will change the scroll height. Any ideas?

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety

      Yes. As mentioned in the video, if you want to make method #1 work you'll need to create a Bool and track whether the textbox has been tapped and only adjust if it hasn't. I just showed people that for demo purposes. If you go with the more advanced solution #2 everything works fine.

    • @SamacInnes
      @SamacInnes Před 2 lety

      @@swiftarcade7632 Sorry I should've clarified, I am having this issue with method #2 - so that when you select a textbox the second time and then dismiss the keyboard there is additional spacing that gets added to the scrollview.

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety +1

      @@SamacInnes Ah. Sorry. I believe you, but I can't seem to replicate the problem. I did run into an issue with there being extra space when applying this technique to a SwiftUI app. But not UIKit. If you download. My suggestion would be to double check the offset values, see if there is anything else affecting the layout in the UI, and maybe start with a fresh project. My example was pretty base and simple. Good luck!

    • @SamacInnes
      @SamacInnes Před 2 lety

      @@swiftarcade7632 Okay thank you for your suggestion! I appreciate the quick reply

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety

      @@SamacInnes No problem!

  • @unonome
    @unonome Před 2 lety

    Can I ask you why? The UI is so simple but you made so much code. Is that the advantage of creating UI programmatically? If you use storyboard, you will reduce the code by 80%. What is the purpose to have more code?

    • @swiftarcade7632
      @swiftarcade7632  Před 2 lety +2

      Hi Haha - great question. Yes the UI is simple. Yes a nib would have saved some code. Just copied this in quickly for demo purposes. If you Google storyboards vs programmatic you'll find some good points for both. Cheers.