Attualmente, qualsiasi app che creo per iPhone/iPad può essere sottoposta a mirroring su Apple TV tramite AirPlay. Tuttavia, anche in modalità orizzontale, occupa solo la parte centrale dello schermo, con il nero sui lati sinistro e destro. Che cosa è tutto da fare per arrivare ad AirPlay a tutto schermo, nel modo in cui hanno fatto app come Real Racing HD?AirPlay per Apple TV Fullscreen
MODIFICA: Per un suggerimento, ho aggiunto tutto il codice che sto usando, e invece di dire al secondo Windows di usare lo stesso controller di visualizzazione radice normalmente, ho impostato un nuovo VC con un colore diverso per vedere se la meccanica sono stati installati correttamente NON sono, come fa ancora il normale mirroring, anche quando gli dicono di usare un VC diverso.
Ecco AppDelegate.h
#import <UIKit/UIKit.h>
@class MainView;
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *tabBarController;
@property (nonatomic, retain) UIWindow *secondWindow;
@end
e parti rilevanti della AppDelegate.m
- (void)checkForExistingScreenAndInitializeIfPresent {
if ([[UIScreen screens] count] > 1) {
// Get the screen object that represents the external display.
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
// Get the screen's bounds so that you can create a window of the correct size.
CGRect screenBounds = secondScreen.bounds;
self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
self.secondWindow.screen = secondScreen;
// Set up initial content to display...
NSLog(@"Setting up second screen: %@", secondScreen);
ViewController *mainView = [[ViewController alloc] init];
self.secondWindow.rootViewController = mainView;
[self.secondWindow makeKeyAndVisible];
// Show the window.
// self.secondWindow.hidden = NO;
}
NSLog(@"Screen count too low");
}
- (void)setUpScreenConnectionNotificationHandlers {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(handleScreenDidConnectNotification:)
name:UIScreenDidConnectNotification object:nil];
[center addObserver:self selector:@selector(handleScreenDidDisconnectNotification:)
name:UIScreenDidDisconnectNotification object:nil];
}
- (void)handleScreenDidConnectNotification:(NSNotification*)aNotification {
UIScreen *newScreen = [aNotification object];
CGRect screenBounds = newScreen.bounds;
if (!self.secondWindow) {
NSLog(@"Initializing secondWindow/screen in notification");
self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
self.secondWindow.screen = newScreen;
// Set the initial UI for the window.
ViewController *mainView = [[ViewController alloc] init];
self.secondWindow.rootViewController = mainView;
} else {
NSLog(@"Second window already initialized.");
}
}
- (void)handleScreenDidDisconnectNotification:(NSNotification*)aNotification {
if (self.secondWindow) {
// Hide and then delete the window.
self.secondWindow.hidden = YES;
self.secondWindow = nil;
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window setRootViewController:tabBarController];
[self setUpScreenConnectionNotificationHandlers];
[self checkForExistingScreenAndInitializeIfPresent];
return YES;
}
Il sistema operativo deve pensare la vostra applicazione è ancora in modalità verticale. – StilesCrisis
@StilesCrisis no, questo è il comportamento per qualsiasi app, indipendentemente dal fatto che sia in orizzontale, mostrerà una visualizzazione in scala centrata. So che è possibile farlo andare a schermo intero su Apple TV, ma non so come. – user717452