Develop
2013.11.20 01:00
[ios] iphone SetDeviceOrientation 화면 강제 회전
조회 수 18515 댓글 0
iphone에서 화면에 대한 회전을 시키기 위한 간단한 코드는..
[[UIDevice currentDevice] setOrientation:orientation] 이다.
하지만, 이 코드는 non-public API 사용으로 인한 리젝 사유가 되므로 사용할 수 없기 때문에 아래와 같이 회전 관련 메서드를 만들어주어야 한다.
//화면 회전 처리
-(void)SetDeviceOrientation:(UIInterfaceOrientation)orientation { //가로보기 강제 if(orientation==UIInterfaceOrientationPortrait) { orientation=UIInterfaceOrientationLandscapeRight; } //세로보기 강제 else if(orientation==UIInterfaceOrientationLandscapeRight) { orientation=UIInterfaceOrientationPortrait; } int radian=0; CGRect viewFrame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration: 0.2]; if(orientation==UIInterfaceOrientationLandscapeLeft || orientation==UIInterfaceOrientationLandscapeRight) { viewFrame = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f); } if(orientation==UIInterfaceOrientationPortrait) { radian=0; } else if(orientation==UIInterfaceOrientationPortraitUpsideDown) { radian=180; } else if(orientation==UIInterfaceOrientationLandscapeRight) { radian=90; } else if(orientation==UIInterfaceOrientationLandscapeLeft) { radian=270; } //뷰 회전 시키기 CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(radian)); self.view.transform=transform; self.view.bounds=viewFrame; [UIView commitAnimations]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
841 | Develop | 프로그램 문서 관리 (Doxygen) | hooni | 2013.04.23 | 16443 |
840 | Develop | 프로그래밍에서 foo, bar 함수의 유래 | hooni | 2013.06.25 | 21481 |
839 | Develop | 프로그래밍 소스 관련 사이트.. | hooni | 2013.04.23 | 16530 |
838 | Develop | 페이팔에서 돈 찾기 (Paypal withdraw) | hooni | 2014.02.20 | 11484 |
837 | Develop | 캘리포니아 운전면허 족보 | hooni | 2017.06.12 | 894 |
836 | Develop | 최근 논문 자료 (2011/01/03, 만현형한테 보낸거..) | hooni | 2013.04.23 | 10366 |
835 | Develop | 참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ | hooni | 2013.04.23 | 12178 |
834 | Develop | 정리할 자료. | hooni | 2015.07.02 | 825 |
833 | Develop | 자주 쓰는 Docker 명령어 alias | hooni | 2020.01.10 | 272350 |
832 | Develop | 이어서 작업할 내용~ | hooni | 2013.11.21 | 0 |
831 | Develop | 웹페이지 성능 테스트 툴 설명 | hooni | 2013.04.23 | 27523 |
830 | Develop | 알고리즘 성능분석 | hooni | 2014.06.24 | 3107 |