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.
Resize a View that is already presented
-
I am presenting a view as a popover. I want to resize the popover and add a tableview. The problem is not adding a tableview but how to go about resizing a view that is already being presented? Any work around or ideas. I would include code but I really haven’t got any! Hee Hee
-
@robertiii I think you can't resize à presented view. A workaround is to prepare your TableView as hidden and when you need to show it, to hide the whole main view by a semi-transparent shield view. Thus your popover view is not really presented but made visible.
Here a quick and dirty example.
The label is only there to show it will be covered by the shield.
The shield is a button so if you tap it, you simulate you tap outside the popover
The buttonItem is there to activate the TableView.
Of course, it is not a real popover thus you would have to compute the positionimport ui v = ui.View() v.background_color = 'white' l = ui.Label() l.text = 'label' l.frame = (10,40,200,32) v.add_subview(l) shield = ui.Button() shield.frame = v.frame shield.flex = 'wh' shield.background_color = (1,1,1, 0.5) shield.hidden = True v.add_subview(shield) tv = ui.TableView() tv.frame = (100,50,200,50) tv.row_height = 32 tv.data_source = ui.ListDataSource(items=[]) tv.hidden = True v.add_subview(tv) b = ui.ButtonItem() b.title = 'popover' def popover(sender): shield.hidden = False tv.data_source.items.append(str(1+len(tv.data_source.items))) tv.height = len(tv.data_source.items)*tv.row_height tv.hidden = False tv.bring_to_front() b.action = popover v.right_button_items = (b,) def popover_end(sender): shield.hidden = True tv.hidden =True shield.action = popover_end v.present('fullscreen')
-
So I have it presented with an arrow pointing to a menu bar buttonitem.
-
def menuButton(sender): pv = ui.load_view('menuPopOver') pv.name = 'Menu' pv.frame = (0,0,400,149) # x = sender.x + sender.width/2 # y = sender.superview.titlebar_height + sender.y + sender.height/2 pv.present('popover',popover_location = (44.5,50))
-
So I think I should somehow be able to use Transform..... but.... It only scales the view inside the Popup not the bounds of the the Popup itself.
-
You could perhaps turn off clips to bounds.
-
@robertiii said:
So I have it presented with an arrow pointing to a menu bar buttonitem.
I know that but as you can't resize a presented view, what I propose is only a workaround where you can always resize a non presented view.
If you want you can also simulate the triangle of the popover by a path and you simulate the presentation by un hiding the view. And you position your view under a button.
It is easy and you stay the master of the process: present=unhide close=hide -
@robertiii I show you an example of how I use it in a script.
I have a view that is visible when I tap the "geometry" button. It is shown under the button like a popover presented view. All the other objects are hidden by a semi-transparent view, so you only can close the popover view by tapping outside or tap inside it.If I tap a element in the popover view, its size is modified by inserting other infos.
And, if you want, you could draw a little triangle between the button and the popover view to simulate a real popover. I had preferred this way of using the borders to show the link between the two objects.
And so on for other menu buttons...you see the popover view height changing in function of what you tap in it
-
I think I’m starting to follow. Sorry I do enough programming to understand little. HAHA
-
@cvp, looks like a fun app!
-
@mikael yes but never finished, I'm sorry to say it, but already far