0

나는이 질문을 한 번 전에 물었지만 주의력이 0이었고 나를 돕는 사람이 몇 주 안에 반응하지 않았으므로 나를 용서해주세요.하지만 여전히 도움이 필요합니다.방향에 따라 CGAffineTransformMakeRotation이 적용된 UILabel? (ARC, Storyboard, LLDB)

임 CILffineTransformMakeRotation을 사용하여 UILabel을 180 도로 뒤집기 위해 UIOrientationPortrait 및 UIOrientationPortraitUpsideDown을 기준으로 회전을 원합니다. 나는 1/2 결과를 얻을 : 사용자가 라벨 (180)을 변환하고 (여전히 [중요] 홈 버튼을 마주)뿐만 아니라 거꾸로 회전 상하 (세로에서)에 플립 때

하지만

내가 회전 세로로 돌아 가면 라벨이 뒤집힌 회전 상태로 유지되고 홈 버튼과 함께 유지되지 않습니다. 내가 여기

이 함께 .... 도움이 필요이게 무슨 코드 내가 가진 :

#define degreesToRadian(x) (M_PI * (x)/180.0) 

... 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180)); 
} 

답변

2

방향이 무엇이든 상관없이 거꾸로 회전합니다. 당신이 방향에 따라 다르게 회전 할 경우,이 같은 것을 할 필요가 : 장치가 거꾸로있을 때

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    switch(toInterfaceOrientation){ 
    case UIInterfaceOrientationPortrait: 
     TranslateLabel.transform = CGAffineTransformIdentity; 
     break; 
    case UIInterfaceOrientationPortraitUpsideDown: 
     TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180)); 
     break; 
    } 
} 

그 방법, 그것은 거꾸로 레이블을 회전합니다을 그리고로 다시 돌아갑니다 장치가 세로 방향 일 때 정상입니다.

+0

이 작업했지만 UIInterfaceOrientationLandscapeLeft 케이스를 추가해야했습니다. 휴식; case UIInterfaceOrientationLandscapeRight : 휴식; 그래서 열거 오류가 사라질 것입니다. –

+1

위 항목 중 하나도 수행되지 않으면 실행될 기본값을 추가 할 수 있으므로 모든 대소 문자를 하나도 추가 할 필요가 없습니다. – EmilioPelaez

+0

위대한 의견, 후속 조치 주셔서 감사합니다! –

0

난 당신이 방향이 경우 위의이 같은 변환 설정, toInterfaceOrientation에 전환 할 생각 UIInterfaceOrientationPortraitUpsideDownCGAffineTransformIdentity 일 때 UIInterfaceOrientationPortrait입니다. (이것은 다른 방향으로의 회전을 허용하지 않는다고 가정합니다.)

관련 문제