已解决 在 iOS 10.2 中,AirPlay 按钮重新出现并且仍然有效。苹果闹鬼!
在 iOS 9 中,我使用这段代码来检测 Airplay 设备。对于部署目标 10.00,它不会出现。在控制中心,我可以找到我的 airplay 设备,但在我的应用程序中,uiview 没有显示任何内容。 根据我的能力,我已经在“背景模式”、音频、AirPlay 和画中画下进行了检查。也许我忘记了这个受祝福的沙盒的一些新设置? 感谢您的耐心等待
@property (weak, nonatomic) IBOutlet UIView *airplay;
MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: airplay.bounds];
[myVolumeView setShowsVolumeSlider:NO];
[myVolumeView setShowsRouteButton:YES];
myVolumeView.transform = CGAffineTransformMakeScale(0.3,0.3);
[myVolumeView setRouteButtonImage:[UIImage imageNamed:@"myIconAirPlay"] forState:UIControlStateNormal];
[airplay addSubview: myVolumeView];
最佳答案
来自苹果文档:
If there is an Apple TV or other AirPlay-enabled device in range, the route button allows the user to choose it. If there is only one audio output route available, the route button is not displayed. https://developer.apple.com/reference/mediaplayer/mpvolumeview
您是否检查过 var areWirelessRoutesAvailable: Bool { get }
在 MPVolumeView
上返回 true 还是 false?
我认为这是你的按钮不再出现的原因,如果 iOS10 更新破坏了一些 Airplay 设备,直到它们也被更新,这就不是新的了。
关于ios - AirPlay 没有出现在 iOS 10 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40037232/