【问题标题】:ios8, Back button disappeared in 'NavigationViewController'ios8,“NavigationViewController”中的后退按钮消失了
【发布时间】:2014-12-05 02:58:50
【问题描述】:

我是 iOS 编程的新手。

问题是属于'NavigationViewController'的后退按钮,

故事板更改时突然丢失。

如你所见,有返回按钮。

单击按钮后缺少返回按钮。

这是我第二个故事板的起点。

- (IBAction)resultClick:(UIButton *)sender {
NSLog(@"결과 보기 버튼 클릭");
UIStoryboard *secondStoryboard =[UIStoryboard storyboardWithName:@"Second" bundle:nil];
UIViewController *initialSecondVC = [secondStoryboard instantiateInitialViewController];
initialSecondVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:initialSecondVC animated:YES completion:nil];

} -> 在第一个情节提要中单击按钮时的动作。

提前致谢。

【问题讨论】:

    标签: ios xcode


    【解决方案1】:

    这是因为您将 segue 指定为模态 (UIModalTransitionStyleFlipHorizo​​ntal)。 模态转换确实会被推到右侧,因此它没有返回按钮。

    您可以制作一个 push segue(这是默认的,因此删除样式的行,并确保故事板中的 segue 设置为 push)或添加一个按钮(某处)来解除 segue。

    【讨论】:

      【解决方案2】:

      https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomSegues/CreatingCustomSegues.html

      尝试自定义 segue 或者您可以避免使用导航栏并将 UIButton 作为后退按钮。

      【讨论】:

        【解决方案3】:

        在你的代码中有这一行:

        initialSecondVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        

        UIModal 是一种用于创建新视图的模态序列。如果您希望拥有后退按钮的功能,您将需要使用 Push Segue 而不是 Modal。它是您使用 (ctrl + drag) 时给出的选项之一。

        如果您想返回,但仍希望在代码 (UIModalTransitionStyleFlipHorizontal) 中使用 Modal 提供的良好 过渡效果,则需要将第二个 View Controller 嵌入到导航控制器并在导航栏中放置一个 UIBarButtonItem,将其命名为“-(IBAction) backButton: (UIBarButtonItem) sender;,并使用与您用于转到第二个视图控制器返回的代码相同的代码。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-06-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-04-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多