Вопрос

У меня есть раскадровка, которая имеет вкладку барный контроллер.Когда устройство вращается, я хочу перейти к другому экрану, то есть не показывать ту же макет вбок, но показать что-то совершенно другое.

в iOS 5 Я достиг этого со следующим кодом в UitabbarControllerDelegate

- (BOOL)shouldAutorotateToInterfaceOrientation:      (UIInterfaceOrientation)interfaceOrientation
{
    if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {    
        [self performSegueWithIdentifier: @"toGraph" sender: self];
    }

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}
.

в iOS 6 Этот метод больше не вызывается.Все методы, которые я могу видеть, если вид вращается, но не когда устройство вращается.

Спасибо заранее.

Это было полезно?

Решение

Так что на самом деле я не должен был искать вращение View , а скорее устройство вращение.После обнаружения класса UideVice я смог использовать код образца AlternateViews (просто поиск альтернативных представлений в организаторе документации), чтобы все, что мне нужно.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.delegate = self;

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification object:nil];

}

- (void)orientationChanged:(NSNotification *)notification
{
    // We must add a delay here, otherwise we'll swap in the new view
    // too quickly and we'll get an animation glitch
    [self performSelector:@selector(showGraphs) withObject:nil afterDelay:0];
}

- (void)showGraphs
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView)
    {
        [self performSegueWithIdentifier: @"toGraph" sender: self];
        isShowingLandscapeView = YES;
    }

    else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView)
    {
        [self dismissModalViewControllerAnimated:YES];
        isShowingLandscapeView = NO;
    }
}
.

Другие советы

Автоторотация изменилась в iOS 6. Вот нить на форумах Apple dev по вопросу: https://devforums.apple.com/thread/166544?Tstart=30

Вот еще несколько потоков: http://www.buzztouch.com/forum/thread.php?tid= 41ED2FC151397D4AD4A5A60 & AMP; CurrentPage= 1

https://www.buzztouch.com/forum/thread. php? fid= b35f4d4f5ef6b293a717eb5 & tid= b35f4d4f5ef6b293a717eb5

Наиболее актуальным постом из них к вашей проблеме, похоже, следующее:

получил его работать ... Для приложений с вкладками заменили эту строку в AppDelegate: [Self.window addsubview: [Self.Rootapp.rootttabbarController]];

с этим: [Self.window.RootviewController= Self.rootapp.roottablebarcontroller View];

А для получения приложений без вкладок, заменили эту строку: [Self.window addsubview: [Self.rootapp.rootnavcontroller]];

с этим: [Self.window.rootviewController= Self.Rootapp.rootnavcontroller View];

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top