Я не могу понять, почему у меня есть эта проблема, но я ..... В основном у меня есть контроллер бар Tabr с навигационным контроллером на одной из вкладок. На этой конкретной вкладке я хочу, чтобы пользователь мог поворачивать устройство и видеть совершенно другое представление, не с первого взгляда повернутого! Чтобы добиться этого (на полном экране), у меня есть LandscapeViewController, который я представляю модально, когда устройство находится в альбомной ориентации. Проблема возникает, когда я представляю modalViewController ..... в LandscapeViewController. Я также проверяю ориентацию, чтобы я мог уволить себя, когда пользователь возвращается в портретный режим. Однако, когда я представляю его, я получаю обратный вызов, говорящий о том, что он переходит в портретный режим, который полностью испортил его! Вот код и войти заявления уточнить, Что творится ..Проблемы с вращением ModalViewController в TabBarController
//in PortraitViewContoller
(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"Norm going Portrait");
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
NSLog(@"Norm going Landscape");
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
(void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5.];
if(portrait){
NSLog(@"dismissed");
[self dismissModalViewControllerAnimated:NO];
}
else{
NSLog(@"presented");
LandscapeOverviewViewController *land = [[LandscapeOverviewViewController alloc]initWithNibName:@"LandscapeOverviewViewController" bundle:nil];
land.delegate = self;
[self presentModalViewController:land animated:NO];
[land release];
}
[UIView commitAnimations];
}
//in LandscapeViewController
(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"Modal is going Portrait");
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
NSLog(@"Modal is going Landscape");
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
(void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
if(portrait){
NSLog(@"calling delegate to dismiss");
[delegate landscapeViewController:self didRotateBack:(YES)];
}
[UIView commitAnimations];
}
и это текстовый журнал
Norm Собирается ландшафта
2010-08-24 15: 29: 40,024 App [ 32461: 207] представлены
2010-08-24 15: 29: 40,026 App [32461: 207] Модальные находится в движении Портрет
2010-08-24 15: 29: 40,026 App [32461: 207] каллусов нг Делегат уволить
2010-08-24 15: 29: 40,027 App [32461: 207] делегат называется
Как вы можете видеть, когда в портретном и поворачивать он делает правильные вещи, представляя landscapevc, но тогда он думает об этом в портрете и пытается уволить?
Может ли кто-нибудь увидеть, где Im идет не так, и apoligies для длины этого, но форматирование кода не будет работать должным образом в противном случае.
Большое спасибо
Жюль
Спасибо за ответ, да, я реализовал shouldAutorotateToInterfaceOrientation :. В итоге я отказался от использования авторотации и просто сделал это в viewlvant viewController. [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; \t [[NSNotificationCenter defaultCenter] addObserver: self selector: имя @selector (detectOrientation): @ Объект UIDeviceOrientationDidChangeNotification: nil]; и повернут при необходимости. Большое спасибо Jules – Jules