ios - AirPlay to Apple TV Fullscreen -


currently, app make iphone/ipad can mirrored apple tv via airplay. however, in landscape mode, takes center part of screen, black on left , right sides. involved getting airplay full-screen, in way apps real racing hd have done?

edit: per suggestion, have added in code using, , instead of telling secondwindow use same root view controller normal, set new vc different color see if mechanics set right. not, still normal mirroring, when telling use different vc.

here 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 

and relevant parts of appdelegate.m

- (void)checkforexistingscreenandinitializeifpresent {     if ([[uiscreen screens] count] > 1) {         // screen object represents external display.         uiscreen *secondscreen = [[uiscreen screens] objectatindex:1];         // screen's bounds can create window of correct size.         cgrect screenbounds = secondscreen.bounds;          self.secondwindow = [[uiwindow alloc] initwithframe:screenbounds];         self.secondwindow.screen = secondscreen;          // set initial content display...         nslog(@"setting second screen: %@", secondscreen);         viewcontroller *mainview = [[viewcontroller alloc] init];         self.secondwindow.rootviewcontroller = mainview;         [self.secondwindow makekeyandvisible];          // show window.         //        self.secondwindow.hidden = no;     }     nslog(@"screen count 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 initial ui window.         viewcontroller *mainview = [[viewcontroller alloc] init];         self.secondwindow.rootviewcontroller = mainview;     } else {         nslog(@"second window initialized.");     } }  - (void)handlescreendiddisconnectnotification:(nsnotification*)anotification {     if (self.secondwindow) {         // hide , delete window.         self.secondwindow.hidden = yes;         self.secondwindow = nil;     } } - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { [window setrootviewcontroller:tabbarcontroller];     [self setupscreenconnectionnotificationhandlers];     [self checkforexistingscreenandinitializeifpresent]; return yes; } 

what involved getting airplay full-screen...

if want dive right in, here start learning windows , screens in ios world: https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/windowandscreenguide/usingexternaldisplay/usingexternaldisplay.html

if want take broader overview first, here aggregation page videos , other tutorials/documentation:

https://developer.apple.com/airplay/

[edit] here's excerpt of code app of mine i'm setting second display. i've taken of links gave you. note: "main" device , "remote" tv.

note: code not production-complete; there still state changes not respond to. connect airplay receiver , turn on mirroring before running this.

i have this:

@interface appdelegate () {     sfcmanagermainviewcontroller *_mainvc;     sfcremotemonitorviewcontroller *_remotevc; }  @end 

the header:

@property (strong, nonatomic) uiwindow *window; @property (strong, nonatomic) uiwindow *secondwindow; 

and this:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch.  [self setupscreenconnectionnotificationhandlers]; [self checkforexistingscreenandinitializeifpresent];  self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; _mainvc = [[sfcmanagermainviewcontroller alloc] initwithnibname:nil bundle:nil]; self.window.rootviewcontroller = _mainvc; [self.window makekeyandvisible]; return yes; }  - (void)checkforexistingscreenandinitializeifpresent {     if ([[uiscreen screens] count] > 1) {         // screen object represents external display.         uiscreen *secondscreen = [[uiscreen screens] objectatindex:1];         // screen's bounds can create window of correct size.         cgrect screenbounds = secondscreen.bounds;          self.secondwindow = [[uiwindow alloc] initwithframe:screenbounds];         self.secondwindow.screen = secondscreen;          // set initial content display...         nslog(@"setting second screen: %@", secondscreen);         _remotevc = [[sfcremotemonitorviewcontroller alloc] initwithnibname:nil bundle:nil];         self.secondwindow.rootviewcontroller = _remotevc;         [self.secondwindow makekeyandvisible];          // show window.         self.secondwindow.hidden = no;     } }  - (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 initial ui window.         _remotevc = [[sfcremotemonitorviewcontroller alloc] initwithnibname:nil bundle:nil];         self.secondwindow.rootviewcontroller = _remotevc;     } else {         nslog(@"second window initialized.");     } }  - (void)handlescreendiddisconnectnotification:(nsnotification*)anotification {     if (self.secondwindow) {         // hide , delete window.         self.secondwindow.hidden = yes;         self.secondwindow = nil;     } } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -