ios - 在 iPad 屏幕上按下 Controller 两次

标签 ios swift ipad navigation segue

我试图通过单击操作表上显示的选项之一来连接到另一个 Controller 。它在 iPhone 屏幕上运行良好,并且正在推送到适当的场景,但在 iPad 上出现问题。我一直在寻找类似的问题,但没有成功。

@IBAction func actionSheet(_ sender: UIButton) {

    let alert = UIAlertController(title: "Please select one of the options", message: nil, preferredStyle: .actionSheet)

    let cancelActionButton = UIAlertAction(title: "Cancel", style: .cancel) { action -> Void in }

    let recipeActionButton = UIAlertAction(title: "Get The Recipe", style: .default) { action in self.performSegue(withIdentifier: "GetRecipeID", sender: self) }

    let facebookActionButton = UIAlertAction(title: "Login with Facebook", style: .default) { action in self.handleCustomFacebookLogin() }

    //actions
    alert.addAction(cancelActionButton)
    alert.addAction(recipeActionButton)
    alert.addAction(facebookActionButton)

    // support ipad
    if let popoverController = alert.popoverPresentationController {
        popoverController.sourceView = sender
        popoverController.sourceRect = sender.bounds
    }
    self.present(alert, animated: true, completion: nil)
}

这种方法也不起作用:

  let viewController = UIStoryboard(name: "Detail", bundle: nil).instantiateViewController(withIdentifier: "DetailsVC") as! DetailsViewController
  let recipeActionButton = UIAlertAction(title: "Get The Recipe", style: .default, handler: { action in
  self.navigationController?.pushViewController(viewcontroller, animated: true)})

从 iPhone 推送时,我在控制台中收到此警告:

pushViewController:animated: called on <UINavigationController 
0x7fd96a81f800> while an existing transition or presentation is 
occurring; the navigation stack will not be updated.

当我从 iPad 触发操作时,这不会显示,但新 Controller 堆叠在顶部。 FirstController , SecondController 单击上一屏幕中的 getRecipe/Login 按钮后。

最佳答案

您可以尝试从另一个操作执行转场

OperationQueue.main.addOperation {   
    self.performSegue(withIdentifier: "GetRecipeID", sender: nil)
}

关于ios - 在 iPad 屏幕上按下 Controller 两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47095877/

相关文章:

iphone - 绘制多个位置之间的 map 路径

操作系统。如何在 .xib 中嵌入 NavigationController?

objective-c - BarButtonItem 因未知原因调整大小

iOS 8 (Swift) 如何摆脱这个错误 : ImageIO: PNG zlib error?

ios - Xcode IME - 快速获取方法调用参数类型的快捷方式?

ios - Swift 单元测试 - 在展开 Optional 值时意外发现 nil

ios - ipad:将一个 UITableViewCell 从一个 UITableViewController 拖放到另一个 UITableViewController 中

ios - 如何使 2 个 CPTXYPlotSpace 都在其中一个 CPTXYPlotSpace 上响应相同的手势?

ios - 图标字体不适用于 RubyMotion 应用程序

ios - MobileSafari(iOS 浏览器): Is there a way to prevent horizontal/vertical scroll "snapping"?