I am writing a graphing app - Landscape positions the content within the portrait's coordinate system. What is the simplest way for my viewController to detect an orientation change?
edit I am aware there is a similar question from sept 2014, but the solution appears code specific - could someone clarify what the simplest way to detect rotation might be? (code explanation good too)
I tried the implementation but keep getting a "expected declaration" error on NSNotificationCenter
(and for clarity's sake, here's the referenced solution:)
In AppDelegate.swift inside the "didFinishLaunchingWithOptions":
`NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil)`
in the AppDelegate class:
func rotated()
{
if(UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation))
{
println("landscape")
}
if(UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation))
{
println("Portrait")
}
}