조회 수 18460 추천 수 0 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
57 Develop 리팩토링 계획안 file hooni 2017.05.15 746
56 Develop 사이버보안실무 발표자료 (2017.06.08) file hooni 2017.06.05 1201
55 Develop 캘리포니아 운전면허 족보 file hooni 2017.06.12 734
54 Develop [android] 간단한 SQLIite 예제 hooni 2017.06.14 1322
53 Develop [android] SQLiteOpenHelper를 이용한 DBManager hooni 2017.06.14 2060
52 Develop [coding] Find all anagrams in a string hooni 2017.06.27 1138
51 Develop [coding] 공부해야 하는거 ㅋㅋ secret hooni 2017.06.27 0
50 Develop [android] 안드로이드 앱 문서 샘플 file hooni 2017.07.11 2103
49 Develop [ios] VIN Scanner (VIN barcode) 스캐너 file hooni 2017.09.16 644
48 Develop [php] mysql_ 과 mysqli_ 의 차이 hooni 2017.12.01 1691
47 Develop [php] Laravel 5.4: Specified key was too long error file hooni 2017.12.04 9221
46 Develop [js] URL 파싱하기 (jQuery 안쓰고) hooni 2017.12.14 1306
45 Develop [js] 문자열에서 숫자만 걸러내기 (jQuery 안쓰고 정규표현식) hooni 2017.12.14 1102
44 Develop [php][laravel] 초간단 MacOS에서 Laravel 개발 환경 구축 hooni 2017.12.15 1869
43 Develop [php][laravel] 라라벨 프로젝트 생성 및 구조 file hooni 2017.12.15 2378
42 Develop [php][laravel] 라라벨 개발환경 세팅하기 (Mac, Window) 2 file hooni 2017.12.15 2574
Board Pagination Prev 1 ... 48 49 50 51 52 53 Next
/ 53