'How to scroll particular views under the scrollview in ios using swift?

I have views like below 75% view is Scrollview and 25% is Bottom Imageview.

enter image description here

childView which is inside scrollviews

enter image description here

My Screen UI

enter image description here

I tried below code as well but not working

  @IBOutlet weak var Scrollview: UIScrollView!

  override func viewDidLoad() {
        super.viewDidLoad()

    Scrollview.contentSize.height = 1000

  }

Now when keyboard is open I am not able to click Create Button..I want to make scroll child view only under the Scrollview..I want to keep my Image in the Bottom fixed.Android I have done..please anyone help me I am new to iOS...



Solution 1:[1]

You can make use of NotificationCenter to receive a notification when the keyboard is open. Add this code into your viewDidLoad() method:

NotificationCenter.default.addObserver(forName: NSNotification.Name.UIKeyboardWillShow, object: nil, queue: nil) { (notification) in
    let keyboardHeight = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0.0

    Scrollview.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: keyboardHeight, right: 0.0)
}


Now you should be able to scroll until you see Create Button.

Note: You will have to adjust the keyboard height value in order to add the correct inset to your Scrollview (in your case subtract the imageView height from the keyboard height value). If not you will add too much inset to the scroll view.

Solution 2:[2]

Try this below library it will definitely solve your problem

https://github.com/michaeltyson/TPKeyboardAvoiding

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vlad Rusu
Solution 2 Gowthaman M