Views 18465 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
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];
}

?

List of Articles
No. Category Subject Author Date Views
693 Develop [js] 자바스크립트 메뉴얼 사이트.. ㅋㅋ hooni 2013.04.23 7410
692 Develop [c++] MFC 모든 헤더와 라이브러리 설명 | [교류]Programming hooni 2013.04.23 7412
691 Develop [php] gd 프로그램.. htm 파일.. ㅋㅋ file hooni 2013.04.23 7414
690 Develop [c] kmp 활용 search file hooni 2013.04.23 7418
689 Develop [jsp] 유효성체크(Client, Server 에서) file hooni 2003.04.23 7423
688 Develop [c] 암호화 알고리즘 DES 구현 ㅋㅋ file hooni 2013.04.23 7433
687 Develop [c] 지폰(gphone) 소스.. 수정(암호화) file hooni 2013.04.23 7434
686 Develop [js] 부모창에서 자식창으로 문자열 전달.. file hooni 2013.04.23 7456
685 Develop [c] 격자 직사각형 넓이 구하기 file hooni 2013.04.23 7457
684 Develop [c] 파일(File) 관련 함수 샘플 코드 file hooni 2003.04.23 7460
683 Develop [c] 간단한 순위 루틴.. (질문에 대한 답변) hooni 2003.04.23 7469
682 Develop [c] 더블(이중) 연결리스트 예제.. file hooni 2013.04.23 7470
681 Develop [js] 이미지 사이즈를 동적으로 조절.. hooni 2013.04.23 7471
680 Develop [c] 시어핀스키 가스킷..(p.582, A.2 - 두번째) hooni 2003.04.23 7479
679 Develop [php] 데이터를 엑셀,워드 형태로 변환할 때 헤더(ms-office) hooni 2013.04.23 7488
678 Develop [chm] 비주얼 C++ 팁 모음 문서 file hooni 2013.04.23 7500
Board Pagination Prev 1 ... 29 30 31 32 33 ... 74 Next
/ 74