如何旋转设备但不改变视图中的任何内容

How to rotate the device but change nothing in the view

我希望用户旋转设备但不改变视图中的任何内容(不要将视图旋转 180 度)。我只想打印一个句子。

这是我的代码 -(它打印句子,但也旋转设备的视图。在这个例子中它是在左边,但向哪一边并不重要):

override func shouldAutorotate() -> Bool {
    if (UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft) {
        println("Device has been rotated.")
    }
    return true
}

改变

return true

return false