我正在尝试在我的应用中启用AirPlay支持.我不是在做视频; 我想将外部显示器用作"第二显示器".
这是我的问题:如果我从AirPlay按钮选择"AppleTV",我的应用程序不会收到通知.我的应用程序获得通知的唯一一次是当我离开我的应用程序时,转到操作系统级别的AirPlay按钮,在那里选择"AppleTV"并打开镜像.如果我关闭镜像,我的应用程序会被告知外部显示器已经消失.
所以:
代码示例如下.在此先感谢您的帮助!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Is there already an external screen?
if (UIScreen.screens.count > 1)]
{
[self prepareExternalScreen:UIScreen.screens.lastObject];
}
// Tell us when an external screen is added or removed.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(externalScreenDidConnect:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(externalScreenDidDisconnect:) name:UIScreenDidDisconnectNotification object:nil];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
// Add AirPlay control to …Run Code Online (Sandbox Code Playgroud) 我已经为iPhone创建了一个应用程序,对于4S我想通过AirPlay支持应用程序的屏幕镜像.
使用System AirPlay选择器并启用镜像,它将镜像应用程序而不会出现任何问题.
我想在应用程序中提供此选择器并使用以下基本代码:
MPVolumeView *volumeView = [ [MPVolumeView alloc] init] ;
[volumeView setShowsVolumeSlider:NO];
[volumeView sizeToFit];
[self.view addSubview:volumeView];
Run Code Online (Sandbox Code Playgroud)
这提供了一个AirPlay选择器,我可以选择Apple TV.但它并不反映AirPlay上的内容.当我进入系统选择器时,它显示已选择AppleTV,并且为了启用镜像,我必须在此处使用开关.
所以问题是,当用户使用应用程序选择器选择AirPlay时,如何在应用程序中启用镜像?
谢谢