简体   繁体   中英

How to get scroll value for keyboard ondrag in iOS Swift?

I am using onDrag functionality to hide keyboard in iOS chat view controller. The problem is I can't get the scroll value when dragging keyboard to hide (I need exactly like whats app messenger keyboard dismiss by using swiping keyboard).

So, I used

NotificationCenter.default.addObserver(self, selector: #selector(keypadWillChange(_:)), name: UIResponder.keyboardDidChangeFrameNotification, object: nil)

Selector,

 @objc func keypadWillChange(_ notification: Notification) {
 
        print("Dragging...")
 }

When I drag the function keypadWillChange is not called. Any other alternatives to solve this problem?

Thanks in advance...

If you are using UITableView , in UIStoryboard do the following.

  1. Go to Attribute Inspector .
  2. In UIScrollView section, there is a keyboard settings item.
  3. Dismiss interactively option in drop down menu behaves exactly as WhatsApp keyboard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM