Develop
2013.11.20 01:00
[ios] iphone SetDeviceOrientation 화면 강제 회전
조회 수 20239 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
373 | Develop | [js] IE에서 인쇄 설정 팁 | hooni | 2013.04.23 | 11948 |
372 | Etc | [php] 싸이월드 이미지 외부 링크 하기(php) | hooni | 2013.04.23 | 17623 |
371 | System/OS |
[doc] 피쳐셀렉션(feature selection using..) 발표 자료
![]() |
hooni | 2013.04.23 | 13532 |
370 | System/OS |
[doc] 네트워크 장비와 라우터 설정 방법 발표 자료
![]() |
hooni | 2013.04.23 | 15211 |
369 | System/OS |
[windows] 인터넷 익스플로러(IE) 도구모음 표시줄에 아이콘 추가
![]() |
hooni | 2013.04.23 | 19090 |
368 | System/OS | [windows] 종료, 재시작, 로그아웃 아이콘 만들기 | hooni | 2013.04.23 | 19082 |
367 | System/OS | [router] 설정과 기본 명령어들 모음 | hooni | 2013.04.23 | 16452 |
366 | System/OS | NAT와 DHCP에 대한 간단한 설명 | hooni | 2013.04.23 | 19158 |
365 | System/OS | [linux] 간단한 find 명령어 설명(업데이트 해야 함) | hooni | 2013.04.23 | 9947 |
364 | Etc |
[flash] 맘에 드는 파이차트
![]() |
hooni | 2013.04.23 | 13589 |
363 | Develop |
[web] 웹 연동 프로그램 모음..
![]() |
hooni | 2013.04.23 | 7966 |
362 | System/OS |
[doc] TCP/IP 강의 자료 (html)
![]() |
hooni | 2013.04.23 | 11945 |