ios - 以编程方式调用时,Popover Segue 崩溃

标签 ios uistoryboard uistoryboardsegue

我正在使用 XCode 4.2 Storyboard。 最初我有一个 Popover Segue 锚定到嵌入导航 Controller 的 UIViewController 上的 UIButton,一切都很好。

现在我需要在执行 segue 之前添加条件行为,因此我执行了以下操作:

  • 删除了segue
  • 从 UIViewController 创建了一个新的 segue
  • 从按钮创建一个 IBAction
  • 在 IBAction 中调用了 [self performSegueWithIdentifier:@"mySegue"sender:self]

应用程序通过 prepareForSegue,但随后抛出 SIGABRT 并记录以下内容

 \*** Assertion failure in -[UIStoryboardPopoverSegue perform], /SourceCache/UIKit_Sim/UIKit-1912.3/UIStoryboardPopoverSegue.m:27

有什么想法吗?我还有其他实例可以很好地处理推送转场。这是我一直提到的行为不端的弹出窗口的案例吗?

最佳答案

也许有点晚了:

anchor 定义了您要显示的弹出窗口的起点,并且未连接到操作。必须设置。

所以当你想以编程方式调用 popover segue 时,你必须分两步完成:

<强>1。将 Segue 连接到 ViewController 您只需从应该执行 segue 的 ViewController 拖动到目标 ViewController,然后选择 Popover。

Connect Segue to ViewController

<强>2。定义标识符这是从您的代码中调用执行 segue 所必需的

<强>3。连接 anchor 您将 anchor 拖到您希望弹出窗口从中开始的对象。在下图中,它是一个 BarButtonItem。注意:这不会自动执行转场! (通过这种方式,您还可以执行一些连接到 BarButtonItem 的操作)

Connect the Anchor

<强>4。从您的代码中调用 segue

    [self performSegueWithIdentifier:@"yourIdentifier" sender:sender];

关于ios - 以编程方式调用时,Popover Segue 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9876698/

相关文章:

ios - 接收器没有标识符为 'contact_segue' 的 segue

ios - perform segue with identifier 和 prepare for segue 之间的区别

ios - html 5 输入日期类型是否足以在所有浏览器中选择日期

ios - 如何在 Storyboard 中使 UiView 尊重百分比

ios - View 不会像在 Storyboard 中那样出现在 iPhone 上

ios - UIStoryboard popViewController

ios - Storyboard 认为 Segue 不存在。但确实如此

ios - 如何确定 IOS 应用程序是否使用框架/框架库

iphone - 在我的头文件中声明方法

ios - iOS 13.4 中的 MPMusicPlayerController.applicationQueuePlayer 错误