我想编写一个使用外部电视的 iPad 应用程序。为了检测外部显示器,我使用推荐的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// ...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidChange:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidChange:) name:UIScreenDidDisconnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidChange:) name:UIScreenModeDidChangeNotification object:nil];
//...
}
// ...
- (void)screenDidChange:(NSNotification *)notification
{
// ...
}
但是,如果我在模拟器中运行它并切换电视的分辨率(或打开或关闭“TV out”),我不会收到通知,但应用程序会以sigterm
.
有没有办法在模拟器中测试这个?