TOF : iOS Keyboard drama (again)

FIRST OFF : this code is all in SWIFT and it is up to the reader to translate to the required Xojo declares or whatever

  1. Dismiss the keyboard on an iPhone (where there is no dismiss key on the keyboard)
    this allows you to just touch any part of the view that isn’t the keyboard
 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
  1. Move the control so it is not covered by the keyboard. I’m not going to post code here as it is a bit complex, but the basic process is
    a) measure the height of the keyboard (it varies depending on device, accessories etc)
    b) move the top (Y) value of the ENTIRE view up by that amount
 override func viewWillAppear(_ animated: Bool) {
        NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)

 override func viewWillDisappear(_ animated: Bool) {
        NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification , object: nil)

  #if os(iOS)
    public func keyboardSlideView(vc:UIViewController,notification: NSNotification?) {
        guard let keyboardFrame = notification?.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else {
        let keyboardHeight: CGFloat
        if #available(iOS 11.0, *) {
            keyboardHeight = keyboardFrame.cgRectValue.height - vc.view.safeAreaInsets.bottom
        } else {
            keyboardHeight = keyboardFrame.cgRectValue.height
        let newTop=self.height-keyboardHeight
        let moveBy=self.scroll$value-newTop
        if moveBy>0 { vc.view.frame = vc.view.frame.offsetBy(dx: 0, dy: -moveBy) }
    public func moveForKeyboard(_ vc:UIViewController,_ control:UIView,_ up: Bool) {
        if up==false {
        } else {
            let globalPoint :CGPoint = (control.superview?.convert(control.frame.origin, to: nil))!
            //       self.scroll$value=globalPoint.y+control.frame.height-vc.view.frame.origin.y
            // changed this value [13Apr2020] to accomodate SafeArea devices

 func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
        return true

   func textFieldDidEndEditing(_ textField: UITextField) { iosDEVICE.moveForKeyboard(self,textField,false) }

this works perfectly in all my Swift apps