Search code examples
objective-ciphoneios8xcode6screen-size

How can I detect a simulated iOS device's screen size?


How can I detect a simulated device's screen size and device name when my app is running in the simulator? I'm simulating iPhone 6 & 6 Plus on iOS 8. All answers I have tried return "simulator" as the device name, like https://github.com/duhovny/DeviceHardware, and similar ones. Thanks!


Solution

  • The following returns a CGRect holding the size of your device's screen in points.

    [[UIScreen mainScreen] bounds];
    

    Note that the following would return the size of your screen without the status bar. Try to think of this as the frame rectangle for your application's window.

    [[UIScreen mainScreen] applicationFrame];