What is the code to directly call an AirPlay action sheet?

I want to know the code to directly call the AirPlay action sheet. I want to get in the code to press the "AirPlay" button. In other words, I would like to name the "AirPlay action sheet" from anywhere. Thank.

+3
source share
1 answer
- (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 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, it will break.

+4
source

Source: https://habr.com/ru/post/1536065/


All Articles