Develop
2013.11.20 01:00
[ios] iphone SetDeviceOrientation 화면 강제 회전
조회 수 18456 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
813 | System/OS | [linux] 기본 명령어 (내공쌓기) | hooni | 2003.04.23 | 14333 |
812 | System/OS | [linux] 계정관리하기(내공쌓기) | hooni | 2003.04.23 | 13157 |
811 | System/OS | [linux] 간단한 vi편집기 사용 명령 | hooni | 2003.04.23 | 13456 |
810 | System/OS | [linux] 간단한 NAT 설정 script | hooni | 2003.04.23 | 12593 |
809 | System/OS | [linux] 간단한 find 명령어 설명(업데이트 해야 함) | hooni | 2013.04.23 | 9111 |
808 | System/OS | [linux] yum 업데이트 시 커널 제외하기 | hooni | 2014.09.11 | 1256 |
807 | System/OS | [linux] X환경 GNOME에서 KDE로 바꾸는 법.. | hooni | 2013.04.23 | 12365 |
806 | System/OS | [linux] Xwindow/Xmanager 사용 | hooni | 2003.04.23 | 13330 |
805 | System/OS | [linux] wget 명령 사용 예제 | hooni | 2020.05.26 | 1430 |
804 | System/OS | [linux] vi 편집기 간단한 명령과 환경설정 | hooni | 2003.04.23 | 11359 |
803 | System/OS | [linux] The Ultimate Wget Download Guide With 15 Awesome Examples | hooni | 2020.05.26 | 795 |
802 | Develop | [linux] tar 명령어 뽀개기.. ㅋㅋ | hooni | 2003.04.23 | 7669 |