Я пытаюсь скрыть изображение в контроллере вида при повороте устройства.Я публикую уведомление в PlayerViewController и слушаю его в делегате приложения, который отвечает за bannerView:
- (void)orientationChanged:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIDeviceOrientationLandscapeLeft) ||
(orientation == UIDeviceOrientationLandscapeRight)) {
bannerView.hidden = ([[self.navigationController visibleViewController] isKindOfClass:[PlayerViewController class]]) ? YES : NO;
} else {
bannerView.hidden = NO;
}
}
PlayerViewController отправляет уведомление, а делегат приложения скрывает bannerView.Однако, когда устройство положено на стол, изображение показывает.Работает нормально, когда устройство удерживается вертикально, но горизонтально изображение появляется ... странно.
Вот код для отправки уведомления:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
... hide other stuff in this view controller
}
Любые идеи, почему происходит такое странное поведение?
Просто еще один кусочек дополнительной информации.В симуляторе изображение показывает, когда устройство находится в перевернутом положении, хотя у меня есть:
- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIDeviceOrientationPortrait) {
return YES;
} else {
return NO;
}
}