代码之家  ›  专栏  ›  技术社区  ›  Midhun Narayan

VIEWDID出现在什么时候self.view.window?.rootViewController?。调用dismission(animated:true,completion:nil)

  •  0
  • Midhun Narayan  · 技术社区  · 6 年前

    我有出租车管理应用程序,其中一个类调用 堆芯控制器 扩展自 使用所有常用函数。这里我们添加了通知观察器和移除器

    override func viewDidAppear(_ animated: Bool) {
        //registering gcm reciever
        super.viewDidAppear(animated)
        NotificationCenter.default.addObserver(self,
                                               selector: #selector(showReceivedGCMMessageCore(_:)),
                                               name: NSNotification.Name(rawValue: appDelegate.messageKey), object: nil)
    }
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: appDelegate.messageKey), object: nil)
    }
    

    我的视图控制器

    class MyViewController: Corecontroller{
      override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
      }
      override func viewDidDisappear(_ animated: Bool) {
         super.viewDidDisappear(animated)
     }
    }
    

    当FCM到达时,它将在内部执行功能 接受请求视图控制器 从我的扩展核心控制器,在这个 接受请求视图控制器

    let appDelegate = UIApplication.shared.delegate as! AppDelegate
        let rootController   = kStoryBoard.main.instantiateViewController(withIdentifier:kViewControllers.mainPage) as! MainViewController
    
        appDelegate.window?.rootViewController = rootController
    
        self.view.window?.rootViewController?.dismiss(animated: true, completion: nil)
    

    已将新的viewcontroller初始化为rootviewcontroller并已解除,但在本例中 我的视图控制器 viewDidAppear() 执行函数只是想知道为什么会发生这种情况?

    0 回复  |  直到 6 年前