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 [js] JSON 컨트롤.. 재귀호출로 값 출력하기 hooni 2013.04.23 28637
692 Develop [js] jQuery, Javascript 모바일(스마트폰) 판단하는 방법 hooni 2015.04.26 2449
691 Develop [js] jQuery 코드 작성시 편리한 HTML 템플릿 hooni 2013.12.17 33071
690 Develop [js] jQuery 치트 시트 hooni 2013.12.18 36253
689 Develop [js] jQuery 충돌 회피 hooni 2013.12.17 38313
688 Develop [js] jQuery 셀랙터(selector) 요약 hooni 2013.12.17 9418
687 Develop [js] jQuery 셀 병합 1 file hooni 2014.09.23 3488
686 Develop [js] jQuery 관련 사이트 링크 모음 hooni 2013.04.23 18237
685 Develop [js] jQuery 관련 문서 ㅎㅎ file hooni 2013.04.23 31221
684 Develop [js] jQuery plugin 요약 hooni 2013.12.20 10700
683 Develop [js] jQuery 배열 루프(each) hooni 2013.12.17 9987
682 Develop [js] jQjuery $ 활용 hooni 2013.12.17 8874
681 Develop [js] Javascript로 만든 포트리스 (2010) 5 file hooni 2017.03.03 2503
680 Develop [js] IE에서 인쇄 설정 팁 hooni 2013.04.23 10899
679 Develop [js] get방식, url이후 모두 그대로 읽어오기.. hooni 2013.04.23 6841
678 Develop [js] e.stopPropagation() VS e.preventDefault () file hooni 2015.04.14 808
Board Pagination Prev 1 ... 29 30 31 32 33 ... 74 Next
/ 74