I want to know code to call the actionsheet AirPlay directly. I want to achieve in the code for "AirPlay button pressed". In other words, I would like to call the "action sheet AirPlay" from anywhere. Thanks.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- (void)showAirPlay
{
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectZero];
[self.view addSubview:volumeView];
for (UIButton *button in volumeView.subviews)
{
if ([button isKindOfClass:[UIButton class]])
{
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
}
}
}
Add the MPVolumeView to your view, and then send control events to the button. Keep in mind that this is very unstable because if Apple adds another UIButton to MPVolumeView, this will break.