-5

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!

Ky -
  • 30,724
  • 51
  • 192
  • 308
MrTourkos
  • 1,922
  • 2
  • 18
  • 22
  • 1
    Can you make your question a bit clearer? Tell us exactly what you want. – Robert Harvey Sep 22 '14 at 19:13
  • 2
    I'll leave it to others to close this one, but it's a likely duplicate of [How to get the screen width and height in iOS?](http://stackoverflow.com/q/5677716/643383) – Caleb Sep 22 '14 at 20:00
  • 1
    I think he's referring to how it appears that the values returned by `[[UIScreen mainScreen] bounds] are wrong. For both iPhone 6 and iPhone 6 Plus it returns 568 for height which is clearly wrong. Maybe a bug? – eremzeit Dec 03 '14 at 01:38
  • @RobertHarvey might be a year or so late, but I've done my best to edit it to what I think OP meant :) – Ky - Feb 17 '16 at 22:35

1 Answers1

0

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];
Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
Joe
  • 2,386
  • 1
  • 22
  • 33
  • 2
    If this is the correct answer, then what does the question have to do with iOS 8 or the new iPhones? – rmaddy Sep 22 '14 at 21:40
  • @rmaddy perhaps nothing. I believe OP was just describing their environment (rather poorly) – Ky - Feb 17 '16 at 20:34