What is the code to call the actionsheet AirPlay directly?

老子叫甜甜 提交于 2019-12-06 09:06:14

问题


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.



来源:https://stackoverflow.com/questions/13262514/what-is-the-code-to-call-the-actionsheet-airplay-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!