繁体   English   中英

在iOS 6中旋转以解雇Segue

[英]Rotate to fire Segue in iOS 6

我的故事板有一个标签栏控制器。 当设备旋转时,我想移动到不同的屏幕,即侧面不显示相同的布局,但显示完全不同的东西。

在iOS 5中,我使用UITabBarControllerDelegate中的以下代码实现了这一点

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

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

在iOS 6中,不再调用此方法。 我可以看到的所有方法都在旋转视图时处理,而不是在旋转设备时处理。

提前致谢。

所以我真的不应该寻找视图旋转,而是设备旋转。 在发现UIDevice类之后,我能够使用AlternateViews示例代码(只是在文档管理器中搜索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 & currentPage = 1

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

从这些问题到您的问题最相关的帖子似乎如下:

有了它的工作......对于选项卡式应用程序,在appDelegate中替换了这一行:[self.window addSubview:[self.rootApp.rootTabBarController view]];

用这个:[self.window.rootViewController = self.rootApp.rootTabBarController view];

要获得非选项卡式应用程序,请替换以下行:[self.window addSubview:[self.rootApp.rootNavController view]];

用这个:[self.window.rootViewController = self.rootApp.rootNavController view];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM