简体   繁体   English

iOS8:在prepareForSegue中将View Controller推入另一个闪烁

[英]iOS8: Pushing View Controller in prepareForSegue for another flashes it

I have 3 View Controllers, conveniently named A, B, C. 我有3个视图控制器,方便命名为A,B,C。
A is presented using a UINavigationController, and has a push segue to C. A是使用UINavigationController呈现的,具有对C的推送功能。

My desired effect is that after performing the segue, C's back button will pop us into B , and then B's back button pop us to A. Effectively, this means that segueing to C will put both B and C onto the stack. 我期望的效果是执行完序列后,C的后退按钮会将我们弹出到B中 ,然后B的后退按钮会将我们弹出到A中。有效地,这意味着对C的序列化会将B和C都放入堆栈。

in iOS7, I've used the following (redacted) code successfully: 在iOS7中,我成功使用了以下(已编辑)代码:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        CViewController *slotViewer = segue.destinationViewController;
        /* Do Stuff */

        BViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"B"];
        [self.navigationController pushViewController:controller animated:NO];   
}

The result appearance was a smooth transition from A to C, while B is loaded and B's ViewWillAppear is only called when clicking on C's back button. 结果外观是从A到C的平滑过渡,同时加载了B,并且仅当单击C的后退按钮时才调用B的ViewWillAppear。

However, on iOS8, this breaks: The transition briefly flashes B on the screen, its viewWillAppear is called, and only then C is shown. 但是,在iOS8上,这会中断:过渡会在屏幕上短暂闪烁B,调用其viewWillAppear,然后仅显示C。

Any idiomatic way to perform this transition in iOS8? 在iOS8中执行转换的任何惯用方式?

I know I can use the method described here but it feels awkward, and I'd rather use the Segues all the way. 我知道我可以使用这里描述的方法但是感觉很尴尬,我宁愿一直使用Segues。

The method (setViewControllers) you linked was designed to do exactly you want. 您链接的方法(setViewControllers)旨在完全按照您的意愿进行。 Why is it awkward? 为什么笨拙? It's provided by Apple.. Besides that there is no way to use segues only. 它由Apple提供。此外,没有办法仅使用segues。 Your previous solution was same like pushing first one programatically and right after second one by interface builder..this is awkward man:). 您以前的解决方案就像以编程方式推送第一个,然后由接口生成器紧随第二个一样。.这很尴尬:)。

Please don't do this. 请不要这样做。 You're not supposed modify the navigation stack like that! 您不应该那样修改导航堆栈! It's awkward. 好尴尬

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

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