
We shall use 2 textView functions to control their behaviour: textViewDidBeginEditing (.) and textViewDidEndEditing(.). There are 2 UITextViews on the New Book view: Synopsis and Notes. TextFieldShouldReturn(.), textFieldDidBeginEditing(.), and textFieldDidEndEditing(.) Each field has a Tag on the Storyboard (e.g., titleTextField.tag = 1) or programmatically by code (see below), and each behaviour is governed by 3 textField functions, which we shall utilise to control the textField attributes and movement by controlling the becomeFirstResponder() function. There are 7 UITextFields on the New Book view: Title, Author, Series, No in Series, Category (Genre), Source, and Format.

NewBookTableViewController.swift contains keyboard control logic, which monitors and detects user taps on the form fields and reacts accordingly. NewBookTableViewController.swift and EditBookTableViewController.swift control the layout, order, and navigation of the corresponding UITableViewControllers. We based the article on the AppsGym Books model app, published on Apple’s App Store (as 8Books), and you can download the complete Xcode project on, for free. The article is for Swift developers who seek complete, integrated, proven, code-centric solutions to speed up their development projects. Then we shall use GestureRecognizer to detect user gestures and check the UITextField or UITextView BeginEditing and EndEditing conditions and animate the fields or views to move them up or down, depending on the keyboard display status. We shall utilise the Delegate feature so the view, as the delegate to the UITextFields and UITextViews, can control the impact of the keyboard display on the positions of UITextFields and UITextViews. The code will ensure that the keyboard does not override (hide) the UITextField or UITextView the user has in focus. Our app will allow users to tap between UITextFields and UITextViews and control the keyboard display (hide or show) as required.

Keyboard Control as User Navigates UITextFields and UITextViews on Table View Form Scenario
