현재 iOS 5의 화면 회전에 문제가 있습니다. iOS 6에서는 모든 것이 정상적으로 작동하지만 회전은 iOS 5에서 작동하지 않습니다. 알림 UIDeviceOrientationDidChangeNotification
이 호출 되더라도. 내 ViewController
같은 방법 내가 여기 Storyboard
를 사용하고있어iOS 5에서는 화면 회전이 작동하지 않지만 iOS 6에서는 작동 중임
는 다음과 같습니다
CustomTabBarViewController.mm (UITabBarController
)
(UINavigationView
)
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return [self.topViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
LoyaltyListController.mm은 (UIViewController
)
- (void) didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
{
self.navigationController.navigationBarHidden = YES;
[self hideTabBar:self.tabBarController];
portraitView.hidden = YES;
landscapeView.hidden = NO;
}
else if (orientation == UIDeviceOrientationPortrait)
{
self.navigationController.navigationBarHidden = NO;
[self showTabBar:self.tabBarController];
portraitView.hidden = NO;
landscapeView.hidden = YES;
[notificationView setFrame:CGRectMake(0, - (notificationView.frame.size.height + 40), notificationView.frame.size.width, notificationView.frame.size.height)];
}
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
[(CustomTabBarViewController*)[self tabBarController] setLandscapeOK:YES];
}
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationMaskAllButUpsideDown);
}
그리고 여기가에서 iOS 5의 화면은 다음과 같습니다
세로 :
풍경 : (하지 않았다 회전)
어떤 생각 : 여기 16,
는 같아야 무엇인가?
아이폰 OS 6에서 iOS 5를 사용- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
를 들어
당신이 내 소스 코드를 확인 했습니까 ??? 그게 정확히 내가 사용하는거야. ... '- (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationMaskAllButUpsideDown); }' – Jeremy
오, 완전히 놓쳤습니다. 다시 확인하십시오! UIInterfaceOrientationMaskAllButUpsideDown을 사용하지 마십시오. interfaceOrientaion 값에 따라 YES 또는 NO 만 리턴하면됩니다. ||을 (를) 사용해야합니다. 그리고 당신이 지원하고 싶은 모든 것을보십시오. upsidedown을 제외한 모든 것을 지원하기 때문에이 방법으로 코드를 작성했습니다. –
사실,'UIInterfaceOrientationMaskAllButUpsideDown'이 iOS6 이상인 것은 아닙니다 :) 지금 테스트 해 보겠습니다. – Jeremy