Domanda

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.

È stato utile?

Soluzione

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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top