Reputation: 13
The code below is returning 0. I've tried all the samples I can find, but it still always returns 0. I'm on XCode 9.4.1
// Screen Size
let screenSize = UIScreen.main.bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
NSLog("Screen Height is %i", screenHeight);
NSLog("Screen Width is %i", screenWidth);
// Screen Size
Upvotes: 0
Views: 791
Reputation:
Just print the statement with print()
print("Screen Height is \(screenHeight)")
print("Screen Width is \(screenWidth)")
In your case, %i
is requesting an integer and screenHeight
and screenWidth
are floats. Therefore use %f
NSLog("Screen Height is %f", screenHeight);
NSLog("Screen Width is %f", screenWidth);
Upvotes: 1
Reputation: 14369
Use print()
print("Screen Height is", screenHeight)
print("Screen Width is", screenWidth)
or by %f
NSLog("Screen Height is %f", screenHeight)
NSLog("Screen Width is %f", screenWidth)
Upvotes: 0