2015-10-17 19 views
0

旋轉UISlider我想我的旋轉,在iPhone的景觀佈局UISlider和使用此代碼它是。CGAffineTransformMakeRotation在viewWillTransitionToSize

self.customSlider.transform = CGAffineTransformMakeRotation(M_PI/2);

不過,我想用它在-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator使其旋轉適當地根據尺寸類別。

我有下面的代碼,我把其他的轉碼

- (空)viewWillTransitionToSize:(CGSize)大小withTransitionCoordinator:(ID)協調{

[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 

if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) { 
    self.stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeRight; 

} 

if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) { 
    self.stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeLeft; 

} 

if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { 
    self.stillCamera.outputImageOrientation = UIDeviceOrientationPortrait; 
} 

}

我想以確保該UISlider是在與滑塊的頂部景觀和左邊底部的右各方向的正確方向。我需要檢查的旋轉,以確保滑塊是在正確的位置,無論在景觀向左或向右用戶從畫像如何旋轉方面。我怎樣才能做到這一點?

編輯: 我使用的GPUImage和預覽視圖使用方向左/右爲該視圖,所以我需要找到一個實現,允許我保持,同時也允許一般大小類定製。

+0

多少方位您的應用程序支持? – Leena

+0

使用規則和緊湊/緊湊的肖像和風景。我可能使用奇怪的特徵集合6 +,但到目前爲止,它看起來很好,只是使用緊湊/緊湊。 – noobsmcgoobs

回答

0

我想通了

第一 - 地方UISlider在容器視圖,並根據需要引腳該容器視圖。

引腳的UISlider在肖像容器視圖 - 無論是用相等的高度/寬度容器水平/垂直居中。

在景觀,根據需要用UISlider銷容器視圖居中H/V具有相等寬度的至容器。

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { 


    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 

    if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) { 
     self.stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeRight; 
     self.customSlider.transform = CGAffineTransformMakeRotation(M_PI/2); 

    } 

    if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) { 
     self.stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeLeft; 
     self.customSlider.transform = CGAffineTransformMakeRotation(M_PI/2); 

    } 

    if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) { 
     self.stillCamera.outputImageOrientation = UIDeviceOrientationPortrait; 
     self.customSlider.transform = CGAffineTransformIdentity; 
    } 

} 
+0

可怕的解決方案.. – Leena

相關問題