xcode 在没有后退按钮的情况下执行 segue?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11380410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:48:49  来源:igfitidea点击:

Perform segue with no back button?

objective-ciosxcodeios5

提问by Darkenor

Is there a way to perform a segue from one of your viewcontroller burried deep within your navigation controller than, when the segue is called, prevents the "back" button from showing up? The justification for this is that after going that deep into the product, we'd rather the user not be able to go back and mess something up.

有没有办法从埋在导航控制器深处的视图控制器中的一个执行转场,而不是在调用转场时阻止“后退”按钮出现?这样做的理由是,在深入了解产品之后,我们希望用户不能回去把事情搞砸。

回答by Mick MacCallum

On the view that should hide the back button, all you have to do is add this line in viewDidLoad.

在应该隐藏后退按钮的视图上,您​​所要做的就是在viewDidLoad.

self.navigationItem.hidesBackButton = YES;

回答by Dibran

I personally like it better to set the hide back button in the source UIViewController instead of the destination UIViewController. This allows you to deffer per segue to enable or disable back navigation. In the viewDidLoadyou will not be able to see which segue was used to instantiate the UIViewController.

我个人更喜欢在源 UIViewController 而不是目标 UIViewController 中设置隐藏返回按钮。这允许您按顺序推迟启用或禁用后退导航。在 中,viewDidLoad您将无法看到使用哪个 segue 来实例化 UIViewController。

Therefore use prepare for segue:

因此使用准备转场:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"segueToHideBackButtonIdentifier"]){
    [segue.destinationViewController.navigationItem setHidesBackButton:YES];
}

回答by joshOfAllTrades

In your -(void)viewWillAppear:(BOOL)animatedyou can call [self.navigationItem setHidesBackButton:YES animated:NO];

-(void)viewWillAppear:(BOOL)animated你可以打电话[self.navigationItem setHidesBackButton:YES animated:NO];

回答by Lachezar Todorov

You have to perform segue as "Show Detail" not just "Show" and the new view will replace the current one

您必须将转场作为“显示详细信息”而不只是“显示”执行,新视图将替换当前视图

enter image description here

在此处输入图片说明