【问题标题】:What is the code to call the actionsheet AirPlay directly?直接调用操作表 AirPlay 的代码是什么?
【发布时间】:2012-11-07 02:55:47
【问题描述】:

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

【问题讨论】:

    标签: iphone objective-c xcode airplay


    【解决方案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];
            }
        }
    }
    

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

    【讨论】:

    • 我想解决多个按钮的问题,可以自定义 AirPlay 按钮图像,这是 MPVolumeView 类上的公共方法,并在迭代按钮时检查它?
    猜你喜欢
    • 2012-07-13
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 2022-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多