2013-02-23 3 views
2

Я делаю приложение, которое будет в обоих режимах как в портретном, так и в ландшафтном. Для iOS 5.0 я добавляю взгляды следуя путем т.е.Вопросы, возникающие при вращении iOS 6.0

-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 

{ 
    if(((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (interfaceOrientation == UIInterfaceOrientationLandscapeRight))) 
{ 
    productname.frame=CGRectMake(240, 97, 106, 20); 
      self.view = landscapeView; 

} 

else if 

(((interfaceOrientation == UIInterfaceOrientationPortrait) || 
      (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))){ 
    productname.frame=CGRectMake(153, 151, 106, 20); 

    self.view = portraitView; 

} 

    return YES; 

}

Но для iOS 6.0 я получил следующие два способа ориентации,

  • (NSUInteger) supportedInterfaceOrientations
  • (BOOL) shouldAutorotate

Мне действительно нужен метод, который должен срабатывать во время вращения устройства. Если у кого есть идея, пожалуйста, дайте мне знать. Я уже потратил много времени на это.

Большое спасибо.

+0

Я не верю, что есть y метод * во время * вращения; только до и после. – trojanfoe

+0

Тогда что мне делать для вращения. Как будут изменяться взгляды во время ротации? –

+0

Что вам нужно сделать в контроллере корневого представления (который * делает * получать уведомление) помещает метод, который вызывает метод «повернуть себя» в верхнем виде. Действительно уродливый, но, очевидно, Apple хочет принудить людей использовать автозапуск. –

ответ

1

Я использую UINavigationController подкласса с помощью следующего кода:

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    if (self.topViewController.presentedViewController) { 
     return self.topViewController.presentedViewController.supportedInterfaceOrientations; 
    } 
    return self.topViewController.supportedInterfaceOrientations; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return self.topViewController.preferredInterfaceOrientationForPresentation; 
} 

и это работа идеально подходит для меня

и в AppDelegate.m файле:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    return [UIDevice isIpad] ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskAllButUpsideDown; 
} 
0

использования

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
Смежные вопросы