How to raise view when keyboard appears in Swift (UITextField and keyboard)
Hi! I'm new to Swift and UIKit, writing a simple notes app. There's a screen with UITextField and UITextView at the bottom. When I tap on the input field, the keyboard covers the bottom part of the screen — I can't see what I'm typing. I tried adding UIScrollView, but it still doesn't work.
Here's an example of my code (everything is in storyboard, outlets are connected):
```swift
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
// Tried to subscribe to keyboard notifications, but don't know how to do it correctly
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotifica
No answers yet.
Log in to leave an answer