Проблемы с ориентацией в ios 6.0

Я уже выполнил свое приложение в книжной ориентации для iPhone и iPad. Теперь мне нужно то же самое для альбомной ориентации, я использовал только xib для iPhone и iPad. И некоторые пользовательские интерфейсы создаются программно. Только сейчас я использовал этот код:

-(NSUInteger)supportedInterfaceOrientations
{
    // return your mask here e.g.:
    if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
        return UIInterfaceOrientationMaskPortrait;
    else
        return UIInterfaceOrientationMaskLandscape;
}

но это не работает должным образом, так что кто-нибудь может мне помочь......?

2 ответа

Решение

Измените этот код следующим:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;  
}

И добавьте следующее:

- (BOOL) shouldAutorotate
{
    return YES;
}

Наконец я сделал это, теперь использую этот код;

- (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration: (NSTimeInterval) duration {if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {// NSLog (@ "Пейзаж слева");

} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    NSLog(@"Landscape right");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
  //  NSLog(@"Portrait");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
   // NSLog(@"Upside down");
}

} Это работало хорошо для любой ориентации, спасибо всем.

Другие вопросы по тегам