ios – Adding UIView with data to the window

I would like in order so as to add a UIView with dimension of tabbar nonetheless exactly above tabbar. This view allow client to return again once more to a started train. My thought is holding info inside UIView and instantiate a View Controller with unfinished info when client clicks button. The problem is that after I must instantiate VC my info in UIView become nil.

    class BeforeRoutineClass {
    // HERE I CREATE the UIView
        func showWorkoutView(temporaryRoutine: Routine) {
       guard let tabBar = navigationController.tabBarController  else { return print("Tabbar is nil") }
            let window = UIApplication.shared.keyWindow!
            let high = tabBar.tabBar.physique.high
            view2 = BackToWorkoutButton(physique: CGRect(x: 0, y: (tabBar.tabBar.physique.origin.y) - high, width: window.physique.width, high: high), routine: temporaryRoutine)

    class BackToWorkoutButton: UIView {
        var routine: Routine?
        init(physique: CGRect, routine: Routine?, bobo: String?) {
            self.routine = routine
            large.init(physique: physique)
        required init?(coder: NSCoder) {
            large.init(coder: coder)
        private func customInit() {
            let xibView = Bundle.foremost.loadNibNamed("BackToWorkoutButton", proprietor: self, selections: nil)?.first as! UIView
            xibView.physique = self.bounds
        @IBAction func backButtonTapped(_ sender: UIButton) {
            // THERE IS NIL ALWAYS
            guard let routine = routine else { return print("Routine is nil") }
            let routineVC = RoutineFactory.startWorkoutScene(routine: routine)
             let navBarOnModal = UINavigationController(rootViewController: routineVC)
             navBarOnModal.modalPresentationStyle = .fullScreen
            guard let nav = UIApplication.shared.dwelling home windows.ultimate?.rootViewController else { return print("there isn't any such factor as a nav")}
             nav.present(navBarOnModal, animated: true, completion: nil)

Supply hyperlink

Leave a Reply

Your email address will not be published.