I locked the app orientation to portrait from the general app setting like this

but still
This would be a comment added to Mohammed Elrashidy solution but I don't have the reputation to make comments. I am using XCode 9.1 and Swift 3.
My app requires some graphing screens to autorotate but all the other screens to remain fixed. My issue was that the "iPad" device configuration in General > Deployment Info was configured inconsistently with the iPhone and Universal devices. I had "Portrait", "Landscape Left" and "Landscape Right" checked for iPhone and Universal but all of the orientations checked for iPad (including "Upside Down"). Simply unchecking "Upside Down" caused the iPad device to honor the shouldAutorotate and supportedInterfaceOrientations calls in my Swift logic.
My Info.plist now looks like the following and I can programmatically turn autorotation on or off for the iPad.
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight