gpt4 book ai didi

swift - 从选项卡栏 View 中的 View 中关闭模式

转载 作者:行者123 更新时间:2023-11-30 11:42:49 26 4
gpt4 key购买 nike

如何关闭从选项卡栏 View 中的 View 打开的模态视图并保留在该 View 上?

登录后我有一个选项卡栏 View ,选项卡 View 上有两个 View (客户和个人资料)。

在客户端上,我有一个客户列表,我可以打开另一个显示发票的 View 。

点击发票,它会显示特定发票的详细信息。

在此 View 上,有一个带有一些按钮的actionView。

其中一个按钮是“付款”。

点击“付款”时,会显示一个模式窗口。

但是,当我点击取消按钮时,它会删除所有 View 并返回到登录 View (初始 View )

发票 View

@IBAction func showActionAlert(_ sender: Any) {
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

let payButton = UIAlertAction(title: "Make Payment", style: .default, handler: { (action) -> Void in

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "MakePaymentViewController")
self.present(controller, animated: true, completion: nil)

})

let voidButton = UIAlertAction(title: "Void", style: .destructive, handler: { (action) -> Void in
})

let deleteButton = UIAlertAction(title: "Delete", style: .destructive, handler: { (action) -> Void in
})

let cancelButton = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in })
alertController.addAction(payButton)
alertController.addAction(voidButton)
alertController.addAction(deleteButton)
alertController.addAction(cancelButton)
self.navigationController!.present(alertController, animated: true, completion: nil)

}

模态视图

 @IBAction func cancelButton(_ sender: Any) {
let tmpController :UIViewController! = self.presentingViewController;
self.dismiss(animated: false, completion: {()->Void in
tmpController.dismiss(animated: true, completion: nil);
});
}

Storyboard

最佳答案

我更改了 cancelButton 操作并且它起作用了:

@IBAction func cancelButton(_ sender: Any) {
dismiss(animated: true, completion: nil)
}

关于swift - 从选项卡栏 View 中的 View 中关闭模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49160157/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com