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;
}