iDev

[iOS Dev] 화면 전환 감지, orientation

KraZYeom 2010. 6. 27. 07:27
반응형


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations
	return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown 
	 || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
	if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
		[self switchToLandscapeOrientation];
	}
	if(toInterfaceOrientation == UIInterfaceOrientationPortrait) {
		[self switchToPortraitOrientation];
	}
	if(toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
		[self switchToPortraitOrientation];
	}
}
반응형