Q & A
글수 1,562
Portrait/Landscape 전환 하는 법 알고 계시는 분 부탁드립니다.
info.plist에
UIInterfaceOrientation 항목에 UIInterfaceOrientationLandscapeRight
설정하는 것 말고
코드로 Portrait / Landscape을 왔다 갔다 하고 싶은데..
UIViewController 에 interfaceOrientation 속성이 있는데
(readonly) 속성이라서 읽어지기는 잘 읽어지는데
어떻게 UIInterfaceOrientationLandscapeRight 로 바꿀 수 있는지..
삽질 중에 참고로 , info.plist에
UIInterfaceOrientation 항목에 UIInterfaceOrientationLandscapeRight
를 설정해도
UIViewController 생성해서 interfaceOrientation 읽어보면
UIInterfaceOrientationPortrait (1)으로 나오고 그래서
혹시 경험 있으신 분들 부탁드립니다.
info.plist에
UIInterfaceOrientation 항목에 UIInterfaceOrientationLandscapeRight
설정하는 것 말고
코드로 Portrait / Landscape을 왔다 갔다 하고 싶은데..
UIViewController 에 interfaceOrientation 속성이 있는데
(readonly) 속성이라서 읽어지기는 잘 읽어지는데
어떻게 UIInterfaceOrientationLandscapeRight 로 바꿀 수 있는지..
삽질 중에 참고로 , info.plist에
UIInterfaceOrientation 항목에 UIInterfaceOrientationLandscapeRight
를 설정해도
UIViewController 생성해서 interfaceOrientation 읽어보면
UIInterfaceOrientationPortrait (1)으로 나오고 그래서
혹시 경험 있으신 분들 부탁드립니다.
2008.10.21 04:39:23
참고하세요.
#define degreesToRadian(x) (M_PI * x / 180.0)
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];//경고는 무시 --;;
// view를 회전 시킴
CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(90));
[해당뷰 view].transform = transform;
// 회전시킨 뷰에 맞게 위치 및 크기 재조정
CGRect contentRect = CGRectMake(0, 0, 480, 320);
[해당뷰 view].bounds = contentRect;
#define degreesToRadian(x) (M_PI * x / 180.0)
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];//경고는 무시 --;;
// view를 회전 시킴
CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(90));
[해당뷰 view].transform = transform;
// 회전시킨 뷰에 맞게 위치 및 크기 재조정
CGRect contentRect = CGRectMake(0, 0, 480, 320);
[해당뷰 view].bounds = contentRect;

AffineTransform으로 ViewDidLoad같은 곳에서 돌려 주세요.
그리고 물론 아시겠지만 최상위 view controller만 interfaceOrientation이 의미가 있습니다.