Contents

조회 수 18456 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
813 System/OS [linux] root 전환시 패스워드 없이 su 사용하기 hooni 2013.12.22 12681
812 Database [mysql] error while loading shared libraries: libmysqlclient.so.10: hooni 2003.04.23 12663
811 Develop [c++] Win32 API 기본 출력인 MessageBox() 함수 사용 예제.. file hooni 2013.04.23 12623
810 System/OS [linux] 간단한 NAT 설정 script hooni 2003.04.23 12593
809 Etc [flash] 맘에 드는 파이차트 file hooni 2013.04.23 12590
808 Database [sql] 간단한 SQL 문법 정리 hooni 2003.04.23 12551
807 PPT [ppt] 네오웹 소프트.. 발표 자료 모음 file hooni 2003.04.23 12550
806 System/OS [doc] 피쳐셀렉션(feature selection using..) 발표 자료 file hooni 2013.04.23 12546
805 PPT [doc] 위탁과제 제안서와 발표자료(pdf) file hooni 2013.04.23 12534
804 System/OS [linux] 스케쥴링 순서(nice) 변경하기 hooni 2003.04.23 12532
803 Develop [c] flooding 알고리즘 미로 찾기(도스용) 소스코드 9 file hooni 2003.04.23 12488
802 Develop [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동 file hooni 2014.01.24 12486
Board Pagination Prev 1 ... 26 27 28 29 30 31 32 33 34 35 ... 98 Next
/ 98