IOS keyboard for textview at backside and searchbar at high

von Satoshi Nakamoto

IOS keyboard for textview at backside and searchbar at high

I've an textview at backside of display and search bar at high of display. Following is my code to resolve the issue of keyboard when textview is pressed



extension UIView
func bindToKeyboard()
NotificationCenter.default.addObserver(self, selector: #selector(UIView.keyboardWillChange(_:)), identify: NSNotification.Title.UIKeyboardWillChangeFrame, object: nil)

@objc func keyboardWillChange(_ notification: NSNotification)
let period = notification.userInfo! as! Double
let curve = notification.userInfo! as! UInt
let curFrame = (notification.userInfo! as! NSValue).cgRectValue
let targetFrame = (notification.userInfo! as! NSValue).cgRectValue
let deltaY = targetFrame.origin.y - curFrame.origin.y

UIView.animateKeyframes(withDuration: period, delay: 0.0, choices: UIViewKeyframeAnimationOptions(rawValue: curve), animations:
self.body.origin.y += deltaY

,completion: (true) in
self.layoutIfNeeded()
)



However after I press search bar then the display strikes up and search bar disappears. If I do view.bindToKeyboard() then the edittext is correct after displaying the keyboard.



One resolution which I attempted was binding the outlet of textview to keyboard however the textview disappears as quickly as I begin typing. Any assist could be appreciated.





Source link

Read the full article
Porträt von Satoshi Nakamoto

Satoshi Nakamoto

Zur Person

Satoshi Nakamoto