0
私は、アクションシートに表示されているオプションの1つをクリックして別のコントローラにセグを試みています。それはiPhoneの画面上でうまく動作し、適切なシーンにプッシュされていますが、問題はiPad上で発生します。私は似たような問題をたくさん探してきましたが、成功しませんでした。コントローラがiPadの画面に2回プッシュされています
@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ボタンをクリックした後。
をセグエを実行しようと、私は、この内部のアクション呼び出しを配置する必要がありますでしょうか? – Vuko
あります。 – Retterdesdialogs
のような同じ位置です。OperationQueue.main.addOperation { self.performSegue(withIdentifier: "GetRecipeID"、送信者:nil)}}のアクション これは残念なことに何も変わりません。 – Vuko