iOS Question Panel is not centered at the first time

Giusy

Active Member
Licensed User
Hi,
I have a menu button that load info.bil
in info.bil I have only a panel.
I center the panel programmatically.
The first time I press Info and the panel is NOT CENTERED, but the second time the panel is CENTERED.
(with breakpoints the panel is immediately centered)
What can I do to overcome the error?
Thanks
 

tufanv

Expert
Licensed User
Longtime User
Can you post your code that centers the panel ?
Hi,
I have a menu button that load info.bil
in info.bil I have only a panel.
I center the panel programmatically.
The first time I press Info and the panel is NOT CENTERED, but the second time the panel is CENTERED.
(with breakpoints the panel is immediately centered)
What can I do to overcome the error?
Thanks
 
Upvote 0

Giusy

Active Member
Licensed User
Yes @tufanv
B4X:
panelinfo.Left=0
    panelinfo.TOP=0

panel5.left=panelinfo.width/2-panel5.width/2
    panel5.top=BtnMENUinfo.Height
    valore=(panelinfo.height-(BtnMENUteoria.Height+panel5.height ))/2+BtnMENUteoria.Height
   
    If valore>BtnMENUteoria.Height Then
        panel5.top=valore
    End If
Panel5 is the panel that I want center
 
Upvote 0

Giusy

Active Member
Licensed User
Hi, @klaus
I have prepared a small program and run it.
And it works properly :( :)
Now I have to analyze where the problem is.
I will check step by step.
Thanks you @klaus you helped me like that
 
Upvote 0

Giusy

Active Member
Licensed User
Hi @klaus
I have clean my project leaving only the part of the panel that ... is not centered
the error occurs on iphone 6
 

Attachments

  • TEST.zip
    4.4 KB · Views: 166
Upvote 0

klaus

Expert
Licensed User
Longtime User
First, you should not put the layout code in the info module but in the DesigherScript.
Then, what exactly do you want?
1. Having Panel5 keeping its with and center it ?
Then, in the Designer set the anchors of Panel5 to Left and Top and use the code below in the DesigerScript:
B4X:
Panel5.HorizontalCenter = 50%x
Panel5.VerticalCenter = (PanelINFO.Height + BtnMENUINFO.Height) / 2

2. Fill the screen width and height with a given margin on each side and on top and bottom?
Then set both anchors to Both.

I would simply use anchors, horizontal and vertical.
 

Attachments

  • TESTNew.zip
    4.6 KB · Views: 162
Upvote 0
Top