-4

How can I get the width of an iOS device in pixels? I don't want to hardcode 320×480 or anything like that... I want to get the width dynamically.

How?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ethan Allen
  • 14,425
  • 24
  • 101
  • 194

1 Answers1

2

One way to get the screen size in pixels (not points) would be:

CGSize screenSize = [UIScreen mainScreen].currentMode.size;

This is easier than using other approaches involving getting the size in points, getting the scale, and doing some math on the two.

rmaddy
  • 314,917
  • 42
  • 532
  • 579