navigationview subview size on iphone
Is it possible to change the size of a navigation subview on an iphone? I have tried setting the frame parameters which hasn't worked. I have tried setting the bound parameters which will affect where the widgets are placed in the subview but not the size of the subview. Is there any way to resize the subview and, if so, how?
Do you mean the size of the navigation view itself? Or the size of the view that the navigation view is displaying?
How are you presenting the view?
I mean the size of the navigation window that is created when invoked. The one that is created is the same size as the primary view window. I create it using a view=ui.view() and sender.navigation_view.push(view)
We need to see code. It is easier to debug Python code than English prose.
This is the portion of the code that is relevant. The main view (named "view") has a button named "AddNext" that when pressed opens a subview from the function "add_next". This all works fine but I would like the subview to be smaller than the main view.
Here is the crux of the code:
add_view = ui.View(frame = (0, 100, 414, 736))
w, h = ui.get_screen_size()
view=ui.View(name='test', bg_color='#D98880', frame=(0, 0, w, h))
add_button = ui.Button(title='AddNext', frame=(250,65,280,100),border_color='black', border_width=2, corner_radius = 10, tint_color = 'black', background_color='yellow', action=add_next, font=('Arial Rounded MT Bold',18))
nav_view = ui.NavigationView(view)
First, it is strange,but
viewis not technically a subview of the navigation view. I forget what it is called, maybe content, or detail. Mostly semantics.
Anyway, the way that navigation views work is that the view that you pass into the navview constructor, or push onto the nav view, gets resized to the navigation view size ( maybe with some offsets to account for the header, but that might be device dependent). The view's rightbuttons and leftbuttons get displayed in the navigation view at the appropriate place, and the title is shown in the nav view title spot.
If your layout code isn't working, or you want larger margin, etc,you can have another container view that goes inside the view you are pushing. Then you have complete control over the size of that inner view (or you can use flex to allow it to scale, but maybe with a proportional border).
That would allow you to layout the view that fits inside the nav view. Note that a
layoutmethod would also let you detect that the view size has changed, and then rearrange the bits inside the view to fit.
If you are asking how you change the size of the outer nav view, on iphone, I don't think you have control over things presented as sheet. On ipad, you could set the size of the navigation view before you present, which would set size of the content to fit.
If you are wanting the next_view to appear as a sort of floating "overlay" on top of the original view, then navigation view is not what you want. Instead, you likely want what is called a "shield" view - a semi transparent view that acts as a container for a smaller overlay window. A search for pythonista shield view should lead you to a class by polymerchm from some years back.