iOS Question BarButton Changes Position Between Pages

Discussion in 'iOS Questions' started by mmieher, Feb 13, 2019.

  1. mmieher

    mmieher Active Member Licensed User

    Everytime I display a new Page, I call a routine that does this:
    Code:
    Dim lbHamburger As BarButton = CreateFABarIcon(Chr(0xF0C9),"Left")
    inParent.ToolbarButtons.Add(lbHamburger)

    Public Sub CreateFABarIcon(text As String, tag As Object) As BarButton
        
    Dim bb As BarButton
        
    Dim b As Button
        b.InitializeCustom(
    "BarButton"Colors.White, Colors.RGB(16,116,74))
        b.CustomLabel.Font = 
    Font.CreateFontAwesome(32)
        b.CustomLabel.TextAlignment = b.CustomLabel.ALIGNMENT_LEFT
        b.Text = text
        b.Tag = tag
        b.SetLayoutAnimated(
    01002424)
        bb.InitializeCustom(b)
        
    Return bb
    End Sub
    What is happening is that the first time the above is called, the button is aligned on the left. The second time, it moves to the right about 100px. The third time it goes back to the left. It keeps alternating like that.

    Neither the b.CustomLabel.ALIGNMENT_LEFT or the SetLayoutAnimated seem to have any effect.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Do you want to add a new icon whenever you add a page?

    Can you upload a small program that demonstrates it?
     
  3. mmieher

    mmieher Active Member Licensed User

    No I don't. Maybe I do not understand the Toolbar? It appears to be associated with a page, so I thought I have to rebuild it every time I display a page?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is indeed associated with a specific page however you only need to create it once when the page is built. Start with building the toolbar with the visual designer (it is in the Main control properties).
     
    mmieher likes this.
  5. mmieher

    mmieher Active Member Licensed User

    I changed code to display the toolbar from the Main module. Once I display a new Page, the Toolbar is still visible but my fontawesome icon is gone. Do I need to use Designer to add icon to every screen?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The simplest way is to add tool bar buttons with the designer. You can create an empty layout with only the buttons and load it on each page.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice