我试图了解UIView
是否可以显示在窗口上,即使没有ViewController
被推到window
上。
这是正确的行为吗?
- 我正试图根据通知显示AppDelegate的"Internet脱机"警报
- 我选择
AppDelegate
是独立于当前堆栈上任何VC的 - 但我发现即使窗口上没有
RootViewController
,我也可以显示Alerts
这是意料之中的事吗?
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor redColor];
[self.window makeKeyAndVisible];
// I am able to show alert here
视图控制器只是在窗口中显示其视图。因此,如果没有视图控制器,就没有理由不能简单地在窗口中显示视图。在显示视图时,视图控制器没有什么特别之处。