直接调用动作表AirPlay的代码是什么? [英] What is the code to call the actionsheet AirPlay directly?

查看:96
本文介绍了直接调用动作表AirPlay的代码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道直接调用操作表AirPlay的代码. 我想在代码中实现按下AirPlay按钮". 换句话说,我想从任何地方调用动作表AirPlay". 谢谢.

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.

推荐答案

- (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];
        }
    }
}

将MPVolumeView添加到您的视图,然后将控制事件发送到该按钮.请记住,这是非常不稳定的,因为如果Apple向MPVolumeView添加另一个UIButton,则它将中断.

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.

这篇关于直接调用动作表AirPlay的代码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆