iOS Question 100%x 100%y weirdness

Discussion in 'iOS Questions' started by sorex, Mar 8, 2015.

  1. sorex

    sorex Expert Licensed User


    I have an iPhone 4s when I look up the specs I see that it should be 640x960.

    When I do a log(100%X) it prints 320 to the log, log(100%y) prints 480.

    What am I missing here?
  2. klaus

    klaus Expert Licensed User

    Look at chapter 5.1 Coordinates in the B4i Beginner's Guide.
  3. sorex

    sorex Expert Licensed User

    thanks, Klaus.
  4. Hugh Thomas

    Hugh Thomas Member Licensed User

    I'm getting some odd results from 100%x and 100%y. I've read the section on coordinates but it doesn't explain what I'm seeing.

    The following piece of code:
    Public NavControl As NavigationController
    Private pPopup As Page

    NavControl.Initialize (

    App.KeyController = NavControl
    Log ("pPopup.rootpanel, width=" & pPopup.RootPanel.Width & ", height=" & pPopup.RootPanel.Height)
    Log ("100%x=" & 100%x & ", 100%y=" & 100%y)
    results in the following log entries:

    pPopup.rootpanel, width=320, height=504
    why is 100%y returning 89?

    This is running on an iPhone 5.

    I don't know if it's relevant, but before these calls I was using a TabControl to manage some other pages, but I expected assigning App.KeyController = NavControl would mean the pages that I display now would be unaffected by what went before in the TabControl.


    Last edited: May 19, 2015
  5. Erel

    Erel Administrator Staff Member Licensed User

    %x and %y are only correct inside Page_Resize events.
  6. Hugh Thomas

    Hugh Thomas Member Licensed User

    That it explains, but makes life a bit more complicated ;^)
  7. billyrudi

    billyrudi Active Member Licensed User

    try to use this
    Dim LV As LayoutValues = GetDeviceLayoutValues
    00, LV.Width,   LV.Height)
  8. Hugh Thomas

    Hugh Thomas Member Licensed User

    Thanks for the suggestion. Does this get the layout values for the currently displayed page (i.e. taking into account space taken up by the TabControl etc)?

    As this problem only affected one routine, which was being passed the rootpanel of the page it was to display on, I ended up getting the width/height of the rootpanel and using that. Another in the long line of hurdles to jump in porting my app to iOS ;^)

  9. Erel

    Erel Administrator Staff Member Licensed User

    The only place where the page size is guaranteed to be correct is inside Page_Resize event.
  10. jazzzzzzz

    jazzzzzzz Active Member Licensed User

    my app only works in portrait ,and page resize will be called just once so how can i responsibly create views in different pages?? without using %x and %y
  11. Erel

    Erel Administrator Staff Member Licensed User

    Note that you should have started a new thread for this question.

    Page_Resize event of each page will fire at least once. However it is better to design the interface with the visual designer and then you don't need to handle this event at all.
  12. jazzzzzzz

    jazzzzzzz Active Member Licensed User

  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