Develop
2013.11.20 01:00
[ios] iphone SetDeviceOrientation 화면 강제 회전
조회 수 18505 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1173 | System/OS |
해커스랩 깨기.. 후후.. ㅋㅋ
![]() |
hooni | 2013.04.23 | 18518 |
1172 | Etc |
플라스터(Plaster) 수업 내용
![]() |
hooni | 2016.05.24 | 0 |
1171 | Develop | 프로그램 문서 관리 (Doxygen) | hooni | 2013.04.23 | 16434 |
1170 | Develop |
프로그래밍에서 foo, bar 함수의 유래
![]() |
hooni | 2013.06.25 | 21458 |
1169 | Develop | 프로그래밍 소스 관련 사이트.. | hooni | 2013.04.23 | 16521 |
1168 | Develop |
페이팔에서 돈 찾기 (Paypal withdraw)
![]() |
hooni | 2014.02.20 | 11465 |
1167 | Etc | 티스토리 테이블 html,css 구문 | hooni | 2013.11.03 | 16042 |
1166 | System/OS | 콘솔에서 패스워드 걸린 zip 압축하는 명령 | hooni | 2018.03.02 | 1115 |
1165 | System/OS |
컴파일러 수업 자료(교재 : 컴파일러 입문)
![]() |
hooni | 2003.04.23 | 22065 |
1164 | Develop |
캘리포니아 운전면허 족보
![]() |
hooni | 2017.06.12 | 869 |
1163 | Etc |
캘리포니아 운전면허 문제
![]() |
hooni | 2017.07.22 | 1162 |
1162 | Develop |
최근 논문 자료 (2011/01/03, 만현형한테 보낸거..)
![]() |
hooni | 2013.04.23 | 10366 |