Airplay mirroring in iOS apps

女生的网名这么多〃 提交于 2019-12-11 10:28:44

问题


I have looked several links and read the Apple Documentation but I don't get any step-wise instructions to mirror the content of app on an external device. All they explain is how to display a new window for an external screen if recognized.

In my app, I just need to display the current screen being shown in the app on an airplay enabled device. There is a airplay button, clicking on which will check for available external screens and display the content present on the device on that screen.


回答1:


Well the reason is simple. AirPlay mirroring is enabled by the user from the settings as @Meera mentioned below. The idea to use in code app is to either display selective things (audio/video) on the TV via AirPlay or to use it as a second Window, where the user does see other things. However if you want you can simply send the whole view to the external screen using this code:

// Check for external screen and if found send output there
if ([[UIScreen screens] count] > 1) {
    UIScreen *externalScreen = [[UIScreen screens] objectAtIndex:1];
    NSArray *screenModes = externalScreen.availableModes;
    //set max resolution
    externalScreen.currentMode = [screenModes lastObject];
    self.window.screen = externalScreen;
}


来源:https://stackoverflow.com/questions/22319776/airplay-mirroring-in-ios-apps

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