Авторотацията не работи ios6.1

Авторотацията не работи в ios6.1. Но следният код работи в друго приложение.

код:

@implementation UINavigationController (RotationIn_IOS6)

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]  preferredInterfaceOrientationForPresentation];
}

@end


- (BOOL)shouldAutorotate
{
    //returns true if want to allow orientation change
    return TRUE;


}
- (NSUInteger)supportedInterfaceOrientations
{
    //decide number of origination tob supported by Viewcontroller.
    return UIInterfaceOrientationMaskAll;


}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    //from here you Should try to Preferred orientation for ViewController

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationPortrait;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)  interfaceOrientation duration:(NSTimeInterval)duration
{

}

person Ram    schedule 08.04.2013    source източник
comment
Проверете настройките на вашия проект за разрешени ориентации - всички поддържани трябва да бъдат избрани, проверете отговора ми тук stackoverflow.com/questions/15835084/   -  person Stas    schedule 08.04.2013
comment
Да, избрах всички ориентации. Но не работи   -  person Ram    schedule 08.04.2013
comment
Приложихте ли този метод в контролерите, които всъщност трябва да се въртят?   -  person Stas    schedule 08.04.2013
comment
да, внедрих във viewcontroller   -  person Ram    schedule 08.04.2013
comment
изглежда, че сте направили печатна грешка някъде, проверете кода си внимателно още веднъж.   -  person Stas    schedule 08.04.2013
comment
Настроихте ли rootViewController на вашия прозорец? Или да добавите подизглед?   -  person Mani    schedule 08.04.2013
comment
HomeVC *home_obj=[[HomeVC alloc]init]; UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:home_obj]; [прозорец addSubview:nav1.view]; //window.rootViewController=nav1; [self.window makeKeyAndVisible];   -  person Ram    schedule 08.04.2013
comment
Да, аз също имах същия проблем. Реших, като зададох window.rootViewCotroller = nav1 ; Можете да опитате това. Надявам се това да е работа..   -  person Mani    schedule 08.04.2013
comment
когато използвам window.rootViewCotroller = nav1. Моят контролер е прозрачен дисплей. Нищо не показва изглед отвътре   -  person Ram    schedule 08.04.2013


Отговори (3)


ios6 използва главно plist опциите за авторотация. Опитайте се да настроите поддържаните полета за ориентация.

person user2256714    schedule 08.04.2013

Опитахте ли да промените plist?

person BalestraPatrick    schedule 08.04.2013

Моля, проверете летните цели на проекта си като по-долу

въведете описание на изображението тук

person dhaya    schedule 09.04.2013
comment
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return YES; } - person dhaya; 10.04.2013
comment
- (BOOL)shouldAutorotate { return YES; } - person dhaya; 10.04.2013
comment
първо премахнете всички методи за ротация в кодирането, след което приложете тези три метода - person dhaya; 10.04.2013