Contents

조회 수 18494 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
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
번호 분류 제목 글쓴이 날짜 조회 수
369 System/OS [linux] wget 명령 사용 예제 hooni 2020.05.26 1580
368 System/OS [linux] Xwindow/Xmanager 사용 hooni 2003.04.23 13376
367 System/OS [linux] X환경 GNOME에서 KDE로 바꾸는 법.. hooni 2013.04.23 12404
366 System/OS [linux] yum 업데이트 시 커널 제외하기 hooni 2014.09.11 1369
365 System/OS [linux] 간단한 find 명령어 설명(업데이트 해야 함) hooni 2013.04.23 9159
364 System/OS [linux] 간단한 NAT 설정 script hooni 2003.04.23 12641
363 System/OS [linux] 간단한 vi편집기 사용 명령 hooni 2003.04.23 13511
362 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13229
361 System/OS [linux] 기본 명령어 (내공쌓기) hooni 2003.04.23 14374
360 System/OS [linux] 기본적인 설정하기(내공쌓기) hooni 2003.04.23 14035
359 System/OS [linux] 기존 환경설정 저장하면서 커널 컴파일.. hooni 2003.04.23 13515
358 System/OS [linux] 꿀통(honeyd) 설치하기.. 메뉴얼 과정 6 file hooni 2006.04.23 20282
Board Pagination Prev 1 ... 63 64 65 66 67 68 69 70 71 72 ... 98 Next
/ 98