omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Slide up view when keyboard is present

    Pythonista
    2
    7
    3880
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mcarrara3
      mcarrara3 last edited by

      Hello, how can I make the view to 'slide up' when the keyboard appears? I need to insert data into a textfield and this gets covered by the keyboard, making it very difficult to edit. Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • Omega0
        Omega0 last edited by

        I place one of these:

        class KeyView (View):
            '''
            A specialty view
            that when placed inside
            a ScrollView allows it to
            slide up automatically
            when the keyboard is opened
            '''
            def keyboard_frame_will_change(self, frame):
                x, y, w, h = frame
                #print frame
                self.superview.content_inset = (0, 0, h + buffer, 0)
                return
                if y < self.superview.height + self.superview.y:
                    self.superview.content_inset = (0, 0, self.superview.height + self.superview.y - y + 6, 0)
                else:
                    self.superview.content_inset = (0, 0, 0, 0)
        

        inside my ScrollView when I want what you're describing.
        It does have to be placed inside a ScrollView though, a normal View won't work.

        1 Reply Last reply Reply Quote 0
        • Omega0
          Omega0 last edited by

          Oh, accidentally used a test version of the code. Here' style real one.

          class KeyView (View):
              '''
              A specialty view
              that when placed inside
              a ScrollView allows it to
              slide up automatically
              when the keyboard is opened
              '''
              def keyboard_frame_will_change(self, frame):
                  x, y, w, h = frame
                  #print frame
                  self.superview.content_inset = (0, 0, h + buffer, 0)
          
          1 Reply Last reply Reply Quote 0
          • Omega0
            Omega0 last edited by

            The buffer variable should be however much room you want between the keyboard and the thing you are editing.

            1 Reply Last reply Reply Quote 0
            • mcarrara3
              mcarrara3 last edited by

              Thanks a lot! This forum is awesome! I am learning a lot!

              1 Reply Last reply Reply Quote 0
              • Omega0
                Omega0 last edited by

                Since the ui module is actually based on Apple's own UIKit you can look up some things like this on Apple's development forums but if you do that be prepared for a sea of technical jargon. Here you get an answer quickly from people who actually speak in layman's terms.

                1 Reply Last reply Reply Quote 0
                • mcarrara3
                  mcarrara3 last edited by

                  Thanks!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors