omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Iphone screen size on an iPad

    Pythonista
    1.6 screen size debugging
    3
    5
    3940
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      I have asked this question before. But it was a while ago. Now you have had access to ctypes for sometime now(magic black box). But are there any low level routines you can access to magically make an iPad think it has the size and resolution as an iPhone 6 or whatever. These values must be lurking around somewhere! Would be a great debugging tool

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by omz

        Just for fun, the script below will resize the entire app to the screen size of an iPhone 6. It'll actually also behave like the iPhone app in most ways (at least on iOS 9, not completely sure if this works on iOS 8 as well, but it might).

        This is actually kinda neat for testing my split-screen support, but as you might expect, some things don't work correctly when the app isn't full-screen, especially things related to the keyboard.

        from objc_util import *
        
        # NOTES: width/height values refer to portrait orientation -- they're automatically
        # swapped if the app is in landscape mode. When this is run with the same values
        # again, the default window size (full-screen) is restored.
        
        # Some things don't work correctly with a non-default window size, e.g. the copy/paste
        # menu is positioned incorrectly.
        
        WIDTH = 375
        HEIGHT = 667
        
        UIWindow = ObjCClass('UIWindow')
        UIApplication = ObjCClass('UIApplication')
        UIScreen = ObjCClass('UIScreen')
        
        @on_main_thread
        def resize_main_window(w, h):
        	app = UIApplication.sharedApplication()
        	win = app.keyWindow()
        	wb = win.bounds()
        	sb = UIScreen.mainScreen().bounds()
        	if sb.size.width > sb.size.height:
        		w, h = h, w
        	if w == wb.size.width and h == wb.size.height:
        		w, h = sb.size.width, sb.size.height
        	
        	win.setBounds_(((0, 0), (w, h)))
        	win.setClipsToBounds_(True)
        
        if __name__ == '__main__':
        	resize_main_window(WIDTH, HEIGHT)
        
        1 Reply Last reply Reply Quote 1
        • Phuket2
          Phuket2 last edited by

          Watch @omz pull another rabbit out of his hat :)
          This is great. Maybe it's not 100%, but I think for a lot of simple testing it will safice. Ok, not used it long, but ran a few things through it, working as expected
          I am glad, I keep asking :)

          1 Reply Last reply Reply Quote 0
          • Tizzy
            Tizzy last edited by

            In Pythonista 3 this doesn't seem like it makes it iPhone Size, unless it's doing iPhone in landscape mode.. Also, if doing while in split screen and then trying to resize, it can make the whole screen of Pythonista turn black until a hard quit.

            Tizzy 1 Reply Last reply Reply Quote 0
            • Tizzy
              Tizzy @Tizzy last edited by

              Sorry correction, it does seem to make it iPhoine size.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors