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
681 Develop [css] z-index에 설정할 수 있는 최대값? hooni 2013.12.20 14708
680 Develop [ios] Objective-C에서 SQLite 사용하기.. file hooni 2013.04.23 14558
679 Develop [ios] iOS In App Purchase #1 (코드 구현 전 웹 설정 작업) file hooni 2013.11.20 14515
678 Develop [c] 메시지큐(Message Queue) 설명.. (joinc) hooni 2013.04.23 14273
677 Develop [c] vc++ 에서 clrscr(), gotoxy() 함수 사용하기.. hooni 2013.04.23 14254
676 Develop [c] 64bit 머신에서 inet_ntoa() 사용시 Segment fault 대처 방법법 hooni 2014.02.08 14233
675 Develop [C] C언어의 조건 연산자(Conditional Operator) hooni 2003.04.23 14227
674 Develop [c] 민수형 libipq 샘플 소스 ㅋㅋ hooni 2003.04.23 14112
673 Develop OPT와 CAS에 대한 자료.. (교수님 메일로 보내드린 자료..) file hooni 2013.04.23 13923
672 Develop [ios] iOS In App Purchase #2 (코드 구현) file hooni 2013.11.20 13773
671 Develop [jsp] Get방식, Post방식 전송 예제.. file hooni 2003.04.23 13762
670 Develop [ios] Hybrid 앱 스터디 발표 자료 file hooni 2013.09.06 13712
669 Develop [iphone] 아이폰 어플 모음 ㅋㅋ secret hooni 2013.04.23 13707
668 Develop [js] window.open() 속성 사용 방법 hooni 2013.11.18 13595
667 Develop [js] 자바스크립트를 동적으로 로딩하기 hooni 2013.04.23 13573
666 Develop [c++] mfc 간단한 파일 입출력 예제 hooni 2013.04.23 13526
Board Pagination Prev 1 ... 9 10 11 12 13 ... 53 Next
/ 53