Views 18458 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 [pdf] C++ 국제 표준 문서 file hooni 2013.04.23 7281
692 Develop [pdf] C 국제 표준 문서 file hooni 2013.04.23 6743
691 Develop [doc] C언어 문법 설명서 file hooni 2013.04.23 6437
690 Develop [doc] C++언어 문법 설명서 file hooni 2013.04.23 6170
689 Develop [chm] 비주얼 C++ 팁 모음 문서 file hooni 2013.04.23 7500
688 Develop [pdf] 윈도우즈 95 시스템 프로그래밍(Windows 95 system programming) file hooni 2013.04.23 6842
687 Develop [chm] 윈도우즈에서 디버깅 기법(Debugging Applications) file hooni 2013.04.23 7527
686 Develop [chm] C++ 문법 가이드 file hooni 2013.04.23 7942
685 Develop [pdf] 포인터 문법 정리 (C pointer) file hooni 2013.04.23 7102
684 Develop [chm] Programming Applications for Microsoft Windows file hooni 2013.04.23 7267
683 Develop [c] Unix Domain Socket 을 이용한 IPC hooni 2013.04.23 8011
682 Develop [c++] 쓰레드(Thread) 객체의 사용 hooni 2013.04.23 8574
681 System/OS [linux] 프로세스의 stat 상태에 대한 설명 hooni 2013.04.23 10756
680 Develop [php] 빔 프로젝터 예약 프로그램.. ㅋㅋ file hooni 2013.04.23 6918
679 Develop [php] 논문 관리 프로그램.. ㅋㅋ file hooni 2013.04.23 7255
678 Develop [c++] 프리렉(freelec) 예제 자료.. ㅋㄷ file hooni 2013.04.23 6833
Board Pagination Prev 1 ... 29 30 31 32 33 ... 74 Next
/ 74