//가로 세로 모드 설정
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
- (void)addObserverForRotation;
- (void)orientationChanged:(NSNotification *)notification;
//초기화때 실행해줘야 함
- (void)addObserverForRotation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)orientationChanged:(NSNotification *)notification
{
/*
typedef enum
{
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;
*/
if([[UIDevice currentDevice] orientation]==3)
{
//_hChartViewController.view.hidden = FALSE;
[window addSubview:_hChartViewController.view];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
CGPoint center = CGPointMake(320 / 2.0, 480 / 2.0);
_hChartViewController.view.center = center;
CGAffineTransform transform = CGAffineTransformMakeRotation(-270 * M_PI / 180);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[_hChartViewController.view setTransform:transform];
[UIView commitAnimations];
}
if([[UIDevice currentDevice] orientation]==4)
{
//_hChartViewController.view.hidden = FALSE;
[window addSubview:_hChartViewController.view];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
CGPoint center = CGPointMake(320 / 2.0, 480 / 2.0);
_hChartViewController.view.center = center;
CGAffineTransform transform = CGAffineTransformMakeRotation(270 * M_PI / 180);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[_hChartViewController.view setTransform:transform];
[UIView commitAnimations];
}
if([[UIDevice currentDevice] orientation]==1)
{
[_hChartViewController.view removeFromSuperview];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
//[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
//_hChartViewController.view.hidden = TRUE;
}
if([[UIDevice currentDevice] orientation]==2)
{
[_hChartViewController.view removeFromSuperview];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
//[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
//_hChartViewController.view.hidden = TRUE;
}
}
'프로그래밍 > iOS' 카테고리의 다른 글
썸네일 처리하기 (0) | 2011.05.04 |
---|---|
앱스토어로 페이지 이동시키기 (0) | 2011.04.18 |
UIColor 값을 RGB로 입력하는 매크로 (0) | 2011.04.08 |
개발시 유용한 자료모음 (0) | 2011.04.08 |
여러가지 Util (0) | 2011.03.29 |