【问题标题】:Present a view modally from the appDelegate swift从 appDelegate swift 以模态方式呈现视图
【发布时间】:2016-07-19 20:25:16
【问题描述】:

I have an NStimer in my AppDelegate,when the interval of time chosen has passed the application needs to present a viewcontroller modally from the selector's timer in the AppDelegate.Is it possible to do that ?

【问题讨论】:

  • 你为什么要在 appdelegate 中这样做?
  • 因为应用程序有多个视图,如果用户不在设置定时器的视图中,我需要定时器不会被破坏
  • 你有计时器是什么意思?无论视图有多长,视图都不会被破坏。编辑您的问题以显示您的故事板。
  • 我没有说视图被破坏,但我说如果用户不在设置定时器的视图控制器中,定时器将不起作用。我需要计时器来处理所有视图控制器
  • 所以有一个视图控制器的主视图,并在其中添加一个计时器。然后做任何你需要做的事情,并根据你的逻辑呈现你想要的特定视图。据了解,AppDelegate 只能显示您想要的根视图,但不能以模态方式呈现。

标签: swift uiviewcontroller presentmodalviewcontroller


【解决方案1】:

AppDelegate 不管理视图。您应该在第一个显示在屏幕上的视图控制器中以模态方式呈现一个 ViewController。

【讨论】:

  • 我有多个视图,而不仅仅是一个视图
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-20
  • 2015-02-27
  • 2020-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多