2013-02-13 4 views
2

Какие все методы необходимы для iOS 6 для ориентации? то, что я использовал, дано ниже, достаточно ли этого?Обращение в iOS6, iPhone?

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 

    if (UIInterfaceOrientationLandscapeLeft == interfaceOrientation || UIInterfaceOrientationLandscapeRight == interfaceOrientation) { 
    return YES; 
    } else { 
     return NO; 
    } 
} 

Я хочу, чтобы сделать работу приложений как в iOS5 и iOS6

ответ

0

перед тем выше всех шагов, установить поддерживаемые ориентации в Targets->Summary ...

enter image description here

+0

выбраны неправильные ориентации! – trojanfoe

+0

@trojanfoe: это просто изображение, чтобы показать, где установить, а не фактическое –

0

Я знаю только iOS5. .. одна небольшая модификация

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    return (UIInterfaceOrientationIsLandscape(interfaceOrientation)); 

} 
0

Да, этих трех достаточно. также для iOS6 добавить preferredInterfaceOrientationForPresentation с возвращением в

return (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight)

метод для запуска приложения в вашей ориентации преимущественного.

0

Для iOS6

//Support all orientation 
- (NSUInteger)application:(UIApplication*)application 
    supportedInterfaceOrientationsForWindow:(UIWindow*)window 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

Теперь вам нужно изменить ваш корневой контроллер представления

// iOS6 support 
// --- 
- (BOOL)shouldAutorotate 
{ 
    return NO; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
return UIInterfaceOrientationMaskLandscape; 
} 

Запрещены в iOS6, по-прежнему необходимой для поддержки iOS5.

// --- 
- (BOOL)shouldAutorotateToInterfaceOrientation: 
    (UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
      interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 
+2

'supportedInterfaceOrientations' ** новый ** в iOS 6.0, не устарел! – trojanfoe

+0

Извините, я положил этот раздел в устаревший заголовок. Исправь это. –

0

Вы просто добавьте следующие строки в файле .m

#define IOS_OLDER_THAN_6 ([ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0) 
#define IOS_NEWER_OR_EQUAL_TO_6 ([ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0) 

Затем необходимо добавить следующие методы в .m файле

#ifdef IOS_OLDER_THAN_6 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)); 
} 
#endif 

#ifdef IOS_NEWER_OR_EQUAL_TO_6 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 
#endif 
Смежные вопросы