【发布时间】:2017-11-03 12:30:26
【问题描述】:
我正在尝试通过单击操作表上显示的选项之一来切换到另一个控制器。它在 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 触发动作时没有显示,但新控制器堆叠在顶部。FirstController, SecondController 在上一个屏幕单击 getRecipe/Login 按钮后。
【问题讨论】:
标签: ios swift ipad navigation segue