【问题标题】:Unwind Segue doesn't exit the view : Objective-CUnwind Segue 不会退出视图:Objective-C
【发布时间】:2015-01-12 17:31:35
【问题描述】:

我使用 Xcode v6.1.1 编写代码

我有两个课程:报告和管理。 当我们在报告(第一个视图)中时,我点击管理按钮,然后出现管理视图(第二个视图)。 当我点击退出按钮(在管理员视图中)时,我希望管理员视图消失并返回报告。

我不知道我是否在代码中出错,但是 NSLog 从 prepareForUnwind 中出现。 Unwind segue 出现在情节提要中并链接到“exit”。展开 segue 标识符:“unwindToContainerVC”操作:prepareForUnwind:

这是我的代码:

Admin.h:

#import <UIKit/UIKit.h>
#import "Reports.h"

@interface Admin : UIViewController

-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue;

@end

管理员.m:

#import "Admin.h"


@interface Admin ()

@end

@implementation Admin

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue {
    NSLog(@"Called unwind action");
}




@end

我必须在 Reports.h 或 Reports.m 中添加一些内容吗? 谢谢!

【问题讨论】:

  • 你的 prepareForUnwind 方法应该在 Reports,你正在展开的 VC,而不是管理员。
  • @pbasdf 好的,我已将 prepareForUnwind 放入报告中,但在情节提要中,我必须使用按钮实现 prepareForUnwind ?
  • 按住 Ctrl 键从按钮拖动到“退出”图标,然后从可能的展开操作列表中选择 prepareForUnwind

标签: ios objective-c segue unwind-segue


【解决方案1】:

您是否将退出按钮连接到情节提要中的“退出”动作?

确保您遵循此处的所有说明:Using Unwind Segues

【讨论】:

  • 是的,我已将 exitButton 拖到情节提要中的“exit”上。 :(
猜你喜欢
  • 2015-02-13
  • 1970-01-01
  • 2023-04-05
  • 2016-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多