ios - Alertview 操作 快速导航到下一个视图控制器后
问题描述
我有两个,当我单击添加按钮时Viewcontrollers
,第一个有一个 AddButton,它导航到第二个,第二个有验证按钮。在验证按钮内单击我正在执行一些验证,然后它导航到我的第一个。一旦它导航我第一次显示它正在工作的警报,但是当我单击 alerview 操作时,它应该导航到第三个。我试过了,但是当我单击 alretview Action OK 按钮时,它没有导航另一个。
这是我的代码ViewController
ViewController
ViewController
ViewController
ViewController
ViewController
ViewController
ViewController
Firstviewcontroller button in side
let lv = NAViewPresenter().otpViewController()
self.navigationController?.pushViewController(lv, animated: true)
In SecondView Controller inside Button,
self.navigationController?.popViewController(animated: true)
OpacityView.shared.showingPopupView(view: self)
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.stopTimer), userInfo: nil, repeats: true)
@objc func stopTimer() {
OpacityView.shared.hidingPopupView()
if (count >= 0){
if(count == 0)
{
self.addAlertViewAction()
}
count -= 1
}
}
func addAlertViewAction() {
let alertController = UIAlertController(title:NAString().add_my_service(), message:NAString().addButtonloadViewMessage(), preferredStyle: .alert)
// Create OK button
let OKAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) in
let lv = NAViewPresenter().myDailyServicesVC()
lv.fromAddMyDailyServicesVC = true
// self.present(lv, animated: true, completion: nil)
self.navigationController?.pushViewController(lv, animated: true)
}
alertController.addAction(OKAction)
self.present(alert, animated: true, completion: nil)
}
解决方案
在第二视图控制器中,
import UIKit
protocol CustomDelegate {
func sendValues(withData : Any)
}
class SecondViewController: UIViewController {
var popupView: PopupView!
var delegate : CustomDelegate?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func popButtonAction() {
self.navigationController?.popViewController(animated: true)
delegate?.sendValues(withData: (Any).self)
}
}
推荐阅读
- python - 无法从 pywinauto 导入:ImportError: DLL load failed while importing win32ui:动态链接库 (DLL) 初始化例程失败
- flutter - Flutter:将 SliverAppbar 与 Column 小部件相结合
- spring-boot - 如何自定义 Spring Data REST 以使用存储库资源的自定义路径?
- python - 使用抓取的字段创建新数据框时出错
- r - purrr::map() 一个深度嵌套的列表,用于测试数据帧的相等性
- api - 我将如何使用 API 密钥来定位网站的 JSON
- bash - How to use SSH access via Bitbucket pipeline for deployment
- heroku - Stripe webhook error 400 bad request when using Heroku web address
- python - 从另一个文件调用 Tkinter 对象
- javascript - How to set a Date value to an object's value that could be undefined in Javascript