ios - iPad simulator and external screen -


i have application wish show on external screen.

the problem when go hardware -> external displays , select 1 of them - events aren't triggered. why?

this doesn't entered:

if ([[uiscreen screens] count] > 1) 

so have added next code:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {      //some code ...      [self checkforexistingscreenandinitializeifpresent];      [self setupscreenconnectionnotificationhandlers];      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;      self.externalwindow=[[externaldisplayviewcontroller alloc]initwithnibname:@"externaldisplayviewcontroller" bundle:nil];     self.externalwindow.view.frame=screenbounds;      self.secondwindow.rootviewcontroller=self.externalwindow;     // set initial content display...     // 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]; } 

addition:

just tried add code in viewdidload

added this:

// check external screen. if ([[uiscreen screens] count] > 1) {  } else { } 

have opened external display , simulator - does't enter if block

the problem might initialisation of externaldisplayviewcontroller :

self.externalwindow=[[externaldisplayviewcontroller alloc]initwithnibname:@"externaldisplayviewcontroller" bundle:nil]; 

try :

[[externaldisplayviewcontroller alloc]initwithnibname:@"externaldisplayviewcontroller" bundle:nil];  uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil];     self.externalwindow= = [storyboard instantiateviewcontrollerwithidentifier:@"externaldisplayview"]; 

and also, need override handlescreendidconnectnotification

-(void)handlescreendidconnectnotification : (nsnotification *)anotification{     uiscreen *newscreen = [anotification object];     cgrect screenbounds = newscreen.bounds;     self.alertfornotifydisplay =  [[uialertview alloc] initwithtitle:@"external display connected." message:nil delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil];     [self.alertfornotifydisplay show];      if (!self.extwindow) {         self.extwindow  = [[uiwindow alloc] initwithframe:screenbounds];         self.extwindow.screen = newscreen;          [self checkforexistingscreenandinitializeifpresent];     }  } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -