相关疑难解决方法(0)

iOS AirPlay:我的应用程序仅在镜像开启时通知外部显示器?

我正在尝试在我的应用中启用AirPlay支持.我不是在做视频; 我想将外部显示器用作"第二显示器".

这是我的问题:如果我从AirPlay按钮选择"AppleTV",我的应用程序不会收到通知.我的应用程序获得通知的唯一一次是当我离开我的应用程序时,转到操作系统级别的AirPlay按钮,在那里选择"AppleTV"并打开镜像.如果我关闭镜像,我的应用程序会被告知外部显示器已经消失.

所以:

  1. 当我从我的应用程序中选择外部显示器时,为什么我的应用程序不会收到通知?
  2. 当我开启镜像时,为什么我的应用会收到有关外部显示器存在的通知...而不是之前?我显然误解了一些东西,但是看起来像镜像应该通知我的应用程序外部显示器已经消失(而不是现在可用,因为操作系统现在应该使用外部显示器进行镜像.)

代码示例如下.在此先感谢您的帮助!

- (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)

ios airplay

6
推荐指数
1
解决办法
8559
查看次数

如何以编程方式在iPhone 4S上打开AirPlay屏幕镜像

我已经为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时,如何在应用程序中启用镜像?

谢谢

iphone ios airplay

5
推荐指数
2
解决办法
8601
查看次数

标签 统计

airplay ×2

ios ×2

iphone ×1