아이폰을 개발하다 보면 회전을 한다든지 세로 또는 가로 고정으로 해야 할 때가 있습니다.
아래 코드는 UIViewController 에서 모든 방향으로 회전이 가능한 코드입니다.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
return 값을 넘겨 줄때 해당 상황에 맞게 넘겨 주면 되겠지요
1. 세로 고정
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown);
}
2. 가로 고정
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft|| interfaceOrientation ==UIInterfaceOrientationLandscapeRight);
}
http://blog.suromind.com/category/IT%EB%B6%84%EC%95%BC/iOS
'옛날' 카테고리의 다른 글
error [iOS] (0) | 2015.12.17 |
---|---|
iOS Open Source [iOS] (0) | 2015.12.17 |
인코딩 (UTF-8) [ios] (0) | 2015.12.17 |
UIWebView에서 user Agent 변경 [IOS] (1) | 2015.12.17 |
webview 동영상 재생 [Android] (0) | 2015.12.17 |