-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
  • 307,833
  • 40
  • 508
  • 550
Ethan Allen
  • 13,766
  • 23
  • 96
  • 185

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
  • 307,833
  • 40
  • 508
  • 550