iOS screen size

I am very sure I’ve seen this before (or even used it) but I can’t find it now.
I need to find the screen size of an iOS device from the opening event.
How can this be achieved?

Self.Size in the opening event.
But if you can’t get any data from that, try using a Timer.CallLater 10, WeakAddressOf CheckResizeMethod to retry the checking a little later.

Sorry, I mean in app.opening

For anyone searching how to do this with declares.

nativeBounds property of UIScreen will return the size.

Something like this:

Private Structure CGSize
  width As CGFloat
  height As CGFloat
End Structure
Private Structure CGRect
  origin as CGPoint
  rsize as CGSize
End Structure
Private Structure CGPoint
  x As CGFloat
  y as CGFloat
End Structure



Declare Function mainScreen Lib "UIKit" selector "mainScreen" (clsRef As ptr) As ptr
Declare Function nativebounds Lib "UIKit" selector "nativeBounds" (obj_id As Ptr) As CGRect
Dim sz As CGSize = nativeBounds(mainScreen(NSClassFromString("UIScreen"))).rsize

Dim w, h As Integer
w = sz.width
h = sz.height
3 Likes