MPVolumeViewWirelessRoutesAvailableDidChangeNotification以不同的值连续调用

时间:2017-11-03 12:53:06

标签: ios ios11 apple-tv

我已将我的应用程序更新为iOS 11 SDK,我遇到了一个非常奇怪的问题。

在应用程序中,我支持AppleTV播放。我使用通知MPVolumeViewWirelessRoutesAvailableDidChangeNotification来监控新无线路由何时可用/不可用。有时升级后我会观察到此通知几乎不断的垃圾邮件。即使更奇怪,areWirelessRoutesAvailable的结果也会在YESNO之间变化。我的通知处理程序代码如下所示:

- (void)appleAvailableRoutesChanged:(NSNotification*)aNotification
{
    MPVolumeView* volumeView = (MPVolumeView*)aNotification.object;
    if(volumeView.areWirelessRoutesAvailable)
    {
        [self addAppleTvButtonToNavBar];
    }
    else
    {
        [self removeAppleTvButtonFromNavBar];
    }
}

我的应用程序的最终结果是AppleTV按钮像疯了一样闪烁,所有其他按钮移动以腾出空间或在消失时缩小间隙。我想补充一点,我的代码暂时没有改变。

示例调试输出:

"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available YES
"MPVolumeViewWirelessRoutesAvailableDidChangeNotification" available NO

注意:我的网络中有几台正在运行的AppleTV进行测试,我确信它们都处于完美的工作状态。当我将它们与网络断开时,一切正常。

是否有人遇到类似的事情。

0 个答案:

没有答案