0
即使打開設備鎖,我也必須開發一個可以旋轉的應用程序。 這是很簡單的檢索設備的當前方位(使用CoreMotion
或[[UIDevice currentDevice].orientation]
有NSTimer
)。強制應用程序旋轉甚至鎖定
但現在我想能夠讓我的所有應用旋轉。
我必須做出visibleViewController
變換或有另一種方式更簡單?
如果我選擇第一個解決方案,我有這種方法稱爲每一步計時器或CoreMotion刷新:
CGAffineTransform transform;
switch (orientation) {
case UIInterfaceOrientationPortrait:
transform = CGAffineTransformMakeRotation(degreesToRadian(0));
case UIInterfaceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(degreesToRadian(180));
case UIInterfaceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(degreesToRadian(90));
case UIInterfaceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
}
[UIView animateWithDuration:0.3f animations:^{
self.view.window.transform = transform;
}];
但它只能一次。 任何想法?