2014-01-29 95 views
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; 
}]; 

但它只能一次。 任何想法?

回答

0

於是我找到一個方法來做到這一點與改造:

self.view.window.layer.transform = CATransform3DMakeRotation(orientationAngle, 0, 0.0, 1.0); 
self.view.window.frame = [[UIScreen mainScreen] bounds]; 

然後我發現我的所有控制器和管理框架。