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.


    How do I scroll all content in scrollview?

    Pythonista
    3
    5
    1245
    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.
    • a9wtPrLyjKTbNH0
      a9wtPrLyjKTbNH0 last edited by ccc

      Hello, can you tell me how to make it possible to add imageview and textview to scrollview. textview should change dynamically from the text placed in it. You need to make sure that when scrolling, all the content(text and image) is scrolled, not just the text.

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

        Something like

        import ui
        sv = ui.ScrollView()
        sv.frame = (0,0,400,600)
        iv = ui.ImageView()
        iv.frame = (0,0,sv.width,200)
        iv.image = ui.Image.named('test:Peppers')
        sv.add_subview(iv)
        tv = ui.TextView()
        tv.frame = (0,iv.height,sv.width,800)
        tv.text = 'a\n'*50
        sv.content_size = (sv.width,iv.height+tv.height)
        sv.add_subview(tv)
        sv.present('sheet')
        
        1 Reply Last reply Reply Quote 1
        • a9wtPrLyjKTbNH0
          a9wtPrLyjKTbNH0 last edited by

          Just what me need, thank you for your help.
          You can't tell me how to make a TextView dynamically change its height so that the textview itself changes its height from the text written in it.

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @a9wtPrLyjKTbNH0 last edited by

            @a9wtPrLyjKTbNH0 you could play with this script but I'm almost sure that @mikael would give a better way with his anchor module

            import ui
            from objc_util import *
            
            @on_main_thread
            class MyTextViewDelegate (object):
            	def textview_did_change(textview):
            		tvo = ObjCInstance(textview)
            		cgs = tvo.sizeThatFits_(CGSize(textview.width,2000))
            		textview.height = cgs.height
            		sv = textview.superview
            		sv.content_size = (sv.width,sv['iv'].height+textview.height+4)
            
            sv = ui.ScrollView()
            sv.frame = (0,0,400,600)
            sv.background_color = 'white'
            iv = ui.ImageView(name='iv')
            iv.frame = (0,0,sv.width,200)
            iv.image = ui.Image.named('test:Peppers')
            sv.add_subview(iv)
            tv = ui.TextView()
            tv.delegate = MyTextViewDelegate
            tv.frame = (2,iv.height+2,sv.width-4,100)
            tv.border_width = 1				# only to show height automatically varying
            tv.border_color = 'blue'
            tv.corner_radius = 5
            tv.text = 'a\n'*20
            sv.add_subview(tv)
            tv.delegate.textview_did_change(tv)	# only to compute initial height
            sv.present('sheet')
            
            1 Reply Last reply Reply Quote 0
            • McDanie1l
              McDanie1l last edited by McDanie1l

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors